Magento: Multi-Site Skin Module

When creating your own custom theme, placing layout changes in a local.xml file is a great way to keep all of your changes in one place, and keeps changes from the core files limited to only what needs changing. However, if you are using the theme in a multi-site setup, if you want to make site specific changes, having to copy the local.xml file into other themes in your package, can quickly lead to a headache maintaining changes to the theme and having to update all of your local.xml files.

One method I have used is to create a module that includes a layout file to be used to place your updates in. For the sake of this post, lets call my namespace SW and our module SiteSkin. Under app/code/local create a directory named SW, under that create a SiteSkin directory with a subdirectory etc. It should look like this:

app/
  code/
    local/
      SW/
        SiteSkin/
          etc/

Inside the etc folder create a config.xml file as follows. This will give you the ability to create a new layout file called siteskin.xml for the child themes in the layout folder of each of the themes.

You will now have the ability to create a package with a default theme where you put your local.xml and all of your base templates, and also create additional themes in your package that use the siteskin.xml to override the core layouts.

NOTE: The local.xml is still read last, so the siteskin.xml won’t override anything in your local.xml file. This is just to make additional changes that are only needed on a per site basis. This could be changed by modifying the getFileLayoutUpdatesXml method in Mage_Core_Model_Layout_Update (code/core/Mage/Core/Model/Layout/Update.php). In the future I will be posting a continuation of this module to include those changes.

Example theme structure:

app/
  design/
    frontend/
      mytheme/
        default/
          layout/
            local.xml
        child1
          layout/
            siteskin.xml
        child2
          layout/
            siteskin.xml

Leave a Reply