|
codeToSelectorReplaceMethodPHP
codeToSelectorReplaceWiki > Syntax > codeTo > codeToSelectorReplace Parameters
Array of raw code, where key is the field. 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 raw executable code replacing 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$code = array( 'field1' => 'print "abba";', 'field2' => 'foreach(array(1, 2, 3) as $i) print $i' ); QueryTemplates formula$template-> codeToSelectorReplace($code) ; Template<?php print "abba"; ?> <?php foreach(array(1, 2, 3) as $i) print $i ?> Template tree beforep.field1 - Text:lorem ipsum p.field2 - Text:lorem ipsum Template tree afterPHP PHP See alsoComments allowed |
Sign in to add a comment