In my custom module, I want to add a custom link in the header, but not within the top links. I can't edit the header.phtml. I prefer add link through layout
2 Answers
The header block is not of type text_list
which would automatically echo all of it's child blocks, therefor you have to manually specify each block that you want to output. In other words, you have to change the header.phtml
template
You should add something in header.phtml
because he can't render automatically all the blocks in content, but you can do it properly like this:
app/design/frontend/{package}/{theme}/layout/local.xml
<reference name="header">
<block type="core/template" name="new.link" template="page/html/header/link.phtml"/>
</reference>
app/design/frontend/{package}/{theme}/template/page/html/header/link.phtml
<a href="#">My new link</a>
app/design/frontend/{package}/{theme}/template/page/html/header.phtml
<?php echo $this->getChildHtml('new.link') ?>