Page 1 of 1

[SOLVED] CallUserTag how to pass and capture value in UDT

Posted: Thu Jan 29, 2015 12:45 pm
by applejack
Using CallUserTag I need to be able to pass and capture a variable value but don't know the syntax?

The value is stored in $this->options["loop"] passed to it from a module call parameter.

The current code is as below with $this->options["udt"] being the name of the UDT.

Code: Select all

$options = UserTagOperations::get_instance()->CallUserTag($this->options["udt"], $tmp);

Re: CallUserTag how to pass and capture value in UDT

Posted: Thu Jan 29, 2015 3:27 pm
by velden
A UDT uses the parameters from the array $params variable.

So give it an array where the key is the expected parameter name and the value is, well, the value.

UDT named 'test':

Code: Select all

// take the value from the 'loop' parameter and add '_changed'. Then return the new string.
return $params["loop"] . '_changed';

Code: Select all

$parameters = array('loop' => 'test-value');
$options = UserTagOperations::get_instance()->CallUserTag("test", $parameters );
$options would contain the string 'test-value_changed'

Re: CallUserTag how to pass and capture value in UDT

Posted: Thu Jan 29, 2015 4:52 pm
by applejack
Many thanks Velden that helped me get it sorted.