0

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

Marius
199k55 gold badges431 silver badges837 bronze badges
asked Feb 2, 2017 at 12:36

1 Answer 1

2

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.

answered Feb 2, 2017 at 12:40
1
  • 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? Commented Feb 3, 2017 at 5:15

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.