So i have a dropdown i created that fires a request to change a theme by saving the selected theme in the current session. I set up an event/observer that changes the theme based on that session variable:


And here is observer method:

public function switchTheme($observer){

    if( Mage::getSingleton('core/session')->getCurrentTheme() ){

        foreach (array('layout', 'template', 'skin', 'locale') as $type) {
            Mage::getDesign()->setTheme($type, Mage::getSingleton('core/session')->getCurrentTheme());


The set up above works for the template files just fine, but the xml layout files(i only have local.xml for now) for the new theme don't seem to be getting loaded in. Is there another event i should observing? Or am i forgetting to update something?

  • 1
    you probably need to refresh the cache Mage::app()->cleanCache(); – pzirkind Mar 28 '14 at 16:37
  • Caching is turned off. I added this to the end of method, still the same. – russjman Mar 28 '14 at 16:44
  • does it help if you manually delete the contents of 'var/cache' – pzirkind Mar 28 '14 at 16:50
  • It does not. Same thing. – russjman Mar 28 '14 at 16:52
  • Check this out: magento.stackexchange.com/questions/8079/… not sure if it will help you (note the event it looks at) – pzirkind Mar 28 '14 at 16:59

Let's say for example you have a basic magento setup and want to change the layout from the normal one to the modern one. The event controller_action_layout_load_before is the one for you as this is done early enough.


Then in your observer you would have something like:

public function changeLayoutEvent($observer) {

Just to make sure I would always set the package and area as magento will not be able to load the theme if the package matches a real package but it does not have the selected theme.


I usually hop right to source on this like this. Some var_dump debugging in

#File: app/code/core/Mage/Core/Model/Design/Package.php
protected function _renderFilename($file, array $params)
    switch ($params['_type']) {
        case 'skin':
            $dir = $this->getSkinBaseDir($params);

        case 'locale':
            $dir = $this->getLocaleBasedir($params);

            $dir = $this->getBaseDir($params);
    return $dir . DS . $file;

Or the subsequent call to getBaseDir

#File: app/code/core/Mage/Core/Model/Design/Package.php
public function getBaseDir(array $params)
    $baseDir = (empty($params['_relative']) ? Mage::getBaseDir('design').DS : '').
    return $baseDir;

Should tell you what file paths Magento's trying to load from before falling back to the defaults. This is often enough to point to the problem with your approach (not changing enough system information, changing it too late)

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.