Magento Tips & Tricks

Render layout block automatically in Magento

There are two types of blocks in magento – one can render automatically and other don’t. If you want to render layout block automatically in Magento you could do following.

  1. Use core/text type. These blocks will render itself automatically. However, this method is not suitable when your block use its own class.
  2. Any block of type core/text_list will automatically render all its children. Just make your block is a child of core/text_list
        <reference name="content">
            <block type="extension/block" template="extension/block.phtml"/>

There are a number of predefined core/text_list blocks in magento layout. Those are:

  • after_body_start
  • topMenu
  • left
  • content
  • right
  • before_body_end

You can use them or create your own blocks for the same purpose.

Learning how render layout block automatically in Magento will allow you to keep your code clean. If you are looking for more information about magento layout blocks try to check Alan Storm’s No Frills Magento Layout.

Leave a Reply

Your email address will not be published. Required fields are marked *