|
varsToSelectorBeforeMethodPHP
varsToSelectorBeforeWiki > Syntax > varsTo > varsToSelectorBefore 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). Defines pattern matching target nodes. %k represents key. Defaults to ".%k", which matches nodes with class name equivalent to variables key (field). For example, to restrict match to nodes with additional class "foo" change $selectorPattern to ".foo.%k" 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 before nodes matched by selector. Method uses actually matched nodes as root for the query. Method doesn't change selected elements stack. ExampleMarkup<p class='field1'>lorem ipsum</p> <p class='field2'>lorem ipsum</p> Data$foo = new stdClass(); $foo->field1 = 'foo'; $foo->field2 = 'bar'; QueryTemplates formula $template->
varsToSelectorBefore('foo', $foo)
;
Template <?php if (isset($foo['field1'])) print $foo['field1'];
else if (isset($foo->{'field1'})) print $foo->{'field1'}; ?><p class="field1">lorem ipsum</p>
<?php if (isset($foo['field2'])) print $foo['field2'];
else if (isset($foo->{'field2'})) print $foo->{'field2'}; ?><p class="field2">lorem ipsum</p>
Template tree beforep.field1 - Text:lorem ipsum p.field2 - Text:lorem ipsum Template tree afterPHP p.field1 - Text:lorem ipsum PHP p.field2 - Text:lorem ipsum See alsoComments allowed |
Sign in to add a comment