I am trying to add a static block to the home page of a Magento site using the layout XML file.
I can see how to add and remove block inside a reference, but I am struggling to see how to add it for a specific page, i.e. the home page.
<block type="cms/block" name="home-page-block">
<action method="setBlockId"><block_id>home-page-block</block_id></action>
</block>
How would I wrap this code in the page.xml
file for it to be only used on the homepage?
Or is there a better way? Should the home page be a new template?
So in order to call any static block, there is no specified way as static block executes automatically when the class is loaded in memory.
In any layout file used by your theme add the following.
<cms_index_index>
<reference name="content">
<block type="cms/block" name="home-page-block">
<action method="setBlockId"><block_id>home-page-block</block_id></action>
</block>
</reference>
</cms_index_index>
cms_index_index
is specific to the home page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With