13

Say there are two themes in a package:

  • Base (Set as default)
  • Child (Set as main theme)

Both contain a local.xml in the layout folder - Only the local.xml from the Child theme will be loaded, so any CSS, JS or layout updates in the Base local.xml do not get loaded.

Without using page.xml (so allowing for the same functionality as local.xml but with inheritance), how would I have an xml file for Base and and one for Child that both get called?

Would this require building a module with a sole purpose of adding a usable xml file (eg: base-local.xml)?

9

You are correct, and this is a valid & used approach for sites with multiple themes. There are a couple of additional (little-known, seldom-used) options which can be used for layout updates which apply to different store scopes: the store handle and the theme handle.

From the action controller superclass Mage_Core_Controller_Varien_Action (link):

public function addActionLayoutHandles()
{
    $update = $this->getLayout()->getUpdate();

    // load store handle
    $update->addHandle('STORE_'.Mage::app()->getStore()->getCode());

    // load theme handle
    $package = Mage::getSingleton('core/design_package');
    $update->addHandle(
        'THEME_'.$package->getArea().'_'.$package->getPackageName().'_'.$package->getTheme('layout')
    );

    // load action handle
    $update->addHandle(strtolower($this->getFullActionName()));

    return $this;
}

For a store with the code 'deutsch' and a theme configuration of 'default' package, 'german' theme, the following handles would apply to almost every view, as most views use them:

<STORE_deutsch>
<THEME_frontend_default_german>

By implementation these handles can be utilized in much the same way as <default />.

  • Ah, that is helpful to know - I think my use-case is slightly different that what you are suggesting though - You would still have one local.xml in a 'base' theme but then use the <THEME_frontend_default_german> to target the child themes from that base theme local.xml - Not have a separate local.xml in each of the child themes? Is that correct or am I misunderstanding? – Glo Jan 25 '13 at 17:09
  • That's it. Unfortunately, the targeted handles apply broadly, so there's no way to, say, "update the root block template for the catalog_product_view page in store X". If, however, store X needs a custom JS file on all pages, it would be possible to use <STORE_x><action method="addJs" block="head"><file>custom/js.js</file></action></STORE_x>. – benmarks Jan 25 '13 at 17:57
  • Thanks a lot, while not specifically what I had in mind, that's some interesting new information, cheers. – Glo Jan 25 '13 at 21:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.