Home » Php » php – Using getChildHtml inside included template magento

php – Using getChildHtml inside included template magento

Posted by: admin July 12, 2020 Leave a comment

Questions:

I am trying to use $this->getChildHtml('head') from inside a page/html/header.phtml file in Magento.

Using $this->getChildHtml('head') inside thh page/1column.phtml file works as expected.

Can someone point me in the right direction to understand how the magic $this is used within templates?

I think this Stack overflow question, Magento – using $this->getPriceHtml on custom page template is on the right lines, but I’m still missing something. Thanks

How to&Answers:

You are getting in to “world inside a world that is bigger than the world that you are inside” syndrome here. You can’t use it because head is not defined a child of your block that you are currently in.

try this instead:

<?php echo $this->getLayout()->getBlock('head')->toHtml();?>