Search code examples
magemagento

Magento Admin custom theme not working


I have a Observer class where i was always used to set new magento template.

<?php

class Company_Customadmintheme_Controller_Observer
{ 
    public function overrideAdminTheme()
    {
        //if(Mage::getStoreConfig('design/admin/enable_admin_custom_theme') == 1)
            Mage::getDesign()->setArea('adminhtml')->setTheme('custom');
    }
}

and in my config xml

<?xml version="1.0"?>
<config>
  <global>
    <models>
        <comapnycustomadminthemecontroller>
             <class>Comapny_Customadmintheme_Controller</class>
        </comapnycustomadminthemecontroller>
    </models>
    <events>
      <adminhtml_controller_action_predispatch_start>
        <observers>
          <comapny_adminthemeoverride_observer>
            <type>singleton</type>
            <class>Comapny_Customadmintheme_Controller_Observer</class>
            <method>overrideAdminTheme</method>
          </comapny_adminthemeoverride_observer>
        </observers>
      </adminhtml_controller_action_predispatch_start>      
    </events>
  </global>
</config>

I have this. Its working fine for Main admin user which was created while installation.

Now we have many admin users who will be able to login and add only products.But for some reason it still showing the magento default template/skin and not picking the custom template(still its working in main admin user who can access all modules/config).

So to make the Catalog users also to see the same template, should i need to specify anything in the xml.

In the observer Class when i tried to see the current template/skin still i see the following array for both users.

object(Mage_Core_Model_Design_Package)#92 (8) {
  ["_store:protected"] => NULL
  ["_area:protected"] => string(9) "adminhtml"
  ["_name:protected"] => string(7) "default"
  ["_theme:protected"] => array(4) {
    ["layout"] => string(6) "custom"
    ["template"] => string(6) "custom"
    ["skin"] => string(6) "custom"
    ["locale"] => string(6) "custom"
  }
  ["_rootDir:protected"] => NULL
  ["_callbackFileDir:protected"] => NULL
  ["_config:protected"] => NULL
  ["_shouldFallback:protected"] => bool(true)
}

Note: My skin/ folder have modifed css for new mage admin and template folder only have page/head.phtml to load extra css.

Please can someone help me in why am not able to see same template for admin/catalog users.


Solution

  • This is not the right way to use a custom theme for your Backoffice.

    Magento already implements this. You just have to put this in any of your config.xml (the one in app/etc or in any of your custom modules.

    <?xml version="1.0" encoding="UTF-8"?>
    <config>
       <stores>
          <admin>
             <design>
                <theme>
                   <default>custom</default>
                </theme>
             </design>
          </admin>
       </stores>
    </config> 
    

    With this, Magento will look for your design templates in app/design/adminhtml/default/custom with a failover on app/design/adminhtml/default/default and your design resources in skin/adminhtml/default/custom with a failover on skin/adminhtml/default/default