سؤال

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)?

هل كانت مفيدة؟

المحلول

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 />.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى magento.stackexchange
scroll top