0

I want to include my custom bolck inside header block, only on <catalog_category_layered>.

So I have this code in local.xml:

<catalog_category_layered>
    <reference name="header">
        <block type="core/template" name="header.catnav" as="header.catnav" template="catalog/catnav.phtml" />
    </reference>
</catalog_category_layered>

And my block is not included. When I change my reference to <reference name="head"> or <reference name="left"> it gets included in these areas.

It doesn't get included in name="content" and name="footer" too.

What do you think am I doing wrong? How do I make my block appear in the header?

2 Answers 2

3

Have you added $this->getChildHtml('header.catnav') to header's template?

Header block does not extend Mage_Core_Block_Text_List block so its children are not displayed automatically. You need to call them in the template.

1
  • I forgot about it. That was exactly the problem. Dziekuje!
    – Alan
    Jul 15, 2015 at 12:14
1

This doesn't work because the header block is different from the others.
the left block is a core/text_list type block. This means it displays all the child blocks, no questions asked.
The head block template contains echo $this->getChildHtml() that does the same thing...displays all the child blocks.

The header block has a separate template that does not call getChildHtml() without any parameters.
It just displays child blocks like this:

echo $this->getChildBlock('block_alias_here')

you need to add a similar line in header.phtml for your block echo $this->getChildHtml('header.catnav')

1
  • This is a very comprehensive answer. Krzysztof was first so I'll accept his but thank you for taking time to write this!
    – Alan
    Jul 15, 2015 at 12:17

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.