|
varsToSelectorAttrMethodPHP
varsToSelectorAttrWiki > Syntax > varsTo > varsToSelectorAttr Parameters
Target attribute name. 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 as attribute of 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->
varsToSelectorAttr('rel', 'foo', $foo)
;
Template <p class="field1" rel="<?php if (isset($foo['field1'])) print $foo['field1'];
else if (isset($foo->{'field1'})) print $foo->{'field1'}; ?>">lorem ipsum</p>
<p class="field2" rel="<?php if (isset($foo['field2'])) print $foo['field2'];
else if (isset($foo->{'field2'})) print $foo->{'field2'}; ?>">lorem ipsum</p>
Template tree beforep.field1 - Text:lorem ipsum p.field2 - Text:lorem ipsum Template tree afterp.field1 - Text:lorem ipsum p.field2 - Text:lorem ipsum See alsoComments allowed |
► Sign in to add a comment