Bruno Oliveira
Bruno Oliveira

Reputation: 33

Magento header block in layout

I have downloaded a custom module in magento that loads a block into layout using a reference:

<reference name="content">
    <block type="ibanner/content_top" name="ibanner_content_top" template="my_ibanner/content/top.phtml" before="-"/>
    <block type="ibanner/content_bottom" name="ibanner_content_bottom" template="my_ibanner/content/bottom.phtml" after="-"/>
</reference>

This code is working fine. However if i use the header refence the banner is not displayed on the page i can't figure out why...

If i use the page_two_columns_left layout and reference the left name layout block, the banner shows up, i can't tell the diference between the blocks to make some of them load the baner and others wont.

If somewone can help me out with this i will really apreciate it.

Regards.

Upvotes: 2

Views: 4130

Answers (1)

benmarks
benmarks

Reputation: 23205

Part of "injecting" a block in different routes depends on the parent block. "content" and "left" are core/text_list blocks (Mage_Core_Block_Text_List), which by design do not use templates and simply render all child blocks. If a block uses a template however, you must (should) take two steps:

  1. Setup the parent/child relationship. Again, in the code above, the two ibanner blocks are being declared as children on the "content" block
  2. Customize the parent block's associated template with the rendering instructions necessary for the child block, e.g. <?php echo $this->getChildHtml("ibanner_content_top") ?>.

Note that template files which contain an empty getChildHtml() call will render all child blocks.

Upvotes: 1

Related Questions