1

I have a scenario such that the childhtml should be called in two different places of same parent template file and for each childhtml is called it should return a phtml which contains the variable getType should be changed.

How is there

------section1------

 $block->getChildBlock('demoPage')->setSection('section1');

  echo $block->getChildHtml('demoPage');

------section2------

  $block->getChildBlock('demoPage')->setSection('section2');

  echo $block->getChildHtml('demoPage');

In child phtml

echo $this->getSection();

The above one is the situation can anyone help this out.

1 Answer 1

2

Try this

//_____________SECTION 1 ____________

$s1Block = $block->getChildBlock('demoPage')->setSection('section1');
echo $s1Block->toHtml();


//_____________SECTION 2 ____________

$s2Block = $block->getChildBlock('demoPage')->setSection('section2');
echo $s2Block->toHtml();

or simply

$block->getChildBlock('demoPage')->setSection('something')->toHtml();

where something will vary in each call.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.