I'm trying to add a custom block for my module into the head
block. I would like this block to be added on every page. Now, my problem is that the block is not rendered at all except if I add the following into one of the files under the design/frontend/<theme>/default/layout/
folder:
<block type="page/html_head" name="head" as="head">
<block type="core/template" name="my_custom_block" template="my_custom_block/custom_block.phtml"></block>
</block>
The layout file for my custom module is located under design/frontend/base/default/layout/my_custom_block.xml
and looks like this:
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="head">
<block type="core/template" name="my_custom_block" template="my_custom_block/custom_block.phtml"></block>
</reference>
</default>
</layout>
I can verify that this file gets loaded by adding a <remove name="root" />
to the layout definition, which in turn will trigger an error when trying to load the page.
Of course I could simply add the block directly into one of the themes templates, but it would be much cleaner if the block is visible just by installing and enabling the module.