2

I would like to know how does Magento blocks pass data to its child blocks. Example:

<reference name="content">
    <block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
        <block type="page/html_pager" name="product_list_toolbar_pager"/>
    </block>
</reference>

Here, if I take the block product_list_toolbar_pager out from product_list_toolbar_pager and create a block of type page/html_pager as a child block for the block catalog.view, it will not receive the data from the current collection I am visiting.

1

That's not about data inheritance but about explicit setting the data to the child block.

Take a look at the method Mage_Catalog_Block_Product_List_Toolbar::getPagerHtml() and you will understand how that works.

The child block is loaded and all the data is set.

If you move the pager outside of the toolbar block you will need to set that missing data somehow in your code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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