Wanted to know , what does getChildHtml() does .need to know the flow of control?

2 Answers 2


getChildHtml() is used to call the child block inside a file corresponding to parent block.

i.e. if you are in a phtml file (say app/design/frontend/default/default/template/catalog/category/view.phtml), it will be first declared in app/design/frontend/default/default/layout/catalog.xml like following:

<block type="catalog/category_view" name="category.products" template="catalog/category/view.phtml">
    <block type="yourmodule/block_name" name="any_name" template="your_folder/xyz.phtml">


  • <block type="yourmodule/block_name" name="any_name" template="your_folder/xyz.phtml"> is a custom block which is the child of category.products block.
  • where your_module is the module name (in lowercase) and block_name represent app/code/local/Your_Namespace/YourModule/Block/Name.php

now, in catalog/category/view.phtml if you call $this->getChildHtml('any_name');, xyz.phtml contents will be rendered there.

getChildHtml() [without parameters] render all the children.

for more details go through these links.

  1. Layouts for a module
  2. Blocks and Layouts
  3. Advanced Layouts

This allows you to include the contents of a secondary Block/Template inside of a primary Block/Template.

Blocks calling Blocks calling Blocks is how the entire HTML layout for your page is created.

getChildHtml() returns the html of the block or all the blocks if you don't pass any parameters.

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.