I have an xml file containing one parent block "P" and inside that a child block "C".
"P" is referring to template "T1" and "C" is referring to template "T2".
Now in "T1" I have a for loop which executes "P" functions and also calls $block->getChildHtml("C") multiple times. "T2" has some html code along with calling functions to "C" block.
But the functions in "T2" are executed only once whereas functions in "T1" are executed multiple times as per the loop.
How do I make the functions of "T2" run multiple times.
The functions in both templates accept parameters due to which I get different result from "T1" template but same result from "T2" template
1 Answer 1
The method getChildHtml has this signature
public function getChildHtml($alias = '', $useCache = true)
The second parameter defaults to true, and if it's true the html of the will be generated only once and cached. The second time you call getChildHtml you will get the same content as the first time.
Change the calls of $block->getChildHtml("C") to $block->getChildHtml("C", false) and it should work.
-
I have a modal which loads the template of "C", I did what you mentioned above and I get different value but the modal shows the value that was loaded first, how can I refresh the modal with new values?Nausif– Nausif2017年02月03日 05:15:57 +00:00Commented Feb 3, 2017 at 5:15