Customizing various XML blocks based on Magento store id
I am currently trying to set up a multi-user version of Magento that will be localized in different countries.
I am trying to specify different xml blocks based on which storefront is being used. For example, on UK version, show UK images, French, show French images, etc.
I have the following local.xml file, but it doesn't seem to change the items, the tags work, although if I put in the delete title tag, for example, it will remove the title block from that store.
<?xml version="1.0" encoding="UTF-8"?>
<layout version="0.1.0">
<default>
</default>
<cms_index_index>
<reference name="root">
<block type="banner/banner" name="banner_home_main" template="unibanner/banner-file.phtml">
<action method="setData">
<name>banner_group_code</name>
<value>home_page_main</value>
</action>
</block>
</reference>
</cms_index_index>
<STORE_name_uk>
<cms_index_index>
<reference name="root">
<action method="unsetChild"><name>banner_home_main</name></action>
<block type="banner/banner" name="banner_home_main" template="unibanner/banner-file.phtml">
<action method="setData">
<name>banner_group_code</name>
<value>home_page_main_uk</value>
</action>
</block>
</reference>
</cms_index_index>
</STORE_name_uk>
</layout>
+3
source to share
1 answer
You don't need to delete blocks for this, you just override them in the STORE_ XML file.
So, in your main local.xml file (the one in the main store), put something like this:
<STORE_name_uk>
<reference name="root">
<block type="banner/banner" name="banner_home_main" template="unibanner/banner-template.phtml">
<action method="setData">
<name>banner_group_code</name>
<value>home_page_main_uk</value>
</action>
</block>
</reference>
</STORE_name_uk>
For some reason I also had to set the "as" value in the start block declaration
+1
source to share