|
varsToStackMethodPHP
varsToStackWiki > Syntax > varsTo > varsToStack Parameters
Variable avaible in scope of type Array or Object. $varName should NOT start with $. Variable value with all fields (keys) OR array of variable fields (keys). Param needs to be passed thou array_keys for non-assosiative arrays. Array of keys from $varValue which should be skipped. Callback triggered after every insertion. Three parameters are passed to this callback: DescriptionInjects executable code printing variable's fields inside actually matched nodes. Second param needs to be wrapped with array_keys for non-assosiative arrays. Method doesn't change selected elements stack. ExampleMarkup<node1> <node2/> </node1> <node2/> <node1> <node2/> </node1> Data$foo = new stdClass(); $foo->first = 'foo'; $foo->second = 'bar'; QueryTemplates formula $template['node1']->
varsToStack('foo', $foo)
;
Template <node1><?php if (isset($foo['first'])) print $foo['first'];
else if (isset($foo->{'first'})) print $foo->{'first'}; ?></node1><node2></node2><node1><?php if (isset($foo['second'])) print $foo['second'];
else if (isset($foo->{'second'})) print $foo->{'second'}; ?></node1>
Template tree beforenode1 - node2 node2 node1 - node2 Template tree afternode1 - PHP node2 node1 - PHP See alsoComments allowed |
Sign in to add a comment