Magento Admin自定义主题不起作用

时间:2012-03-07 11:08:43

标签: mage magento

我有一个Observer类,我总是习惯于设置新的magento模板。

<?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');
    }
}

和我的配置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>

我有这个。它适用于安装时创建的主管理员用户。

现在我们有很多管理员用户可以登录并只添加产品。但由于某种原因,它仍然显示magento默认模板/皮肤而不是选择自定义模板(仍然在主管理员用户中可以访问所有modules / config)。

因此,要使目录用户也看到相同的模板,我是否需要在xml中指定任何内容。

在观察者类中,当我试图看到当前模板/皮肤时,我仍然看到两个用户都有以下数组。

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

注意: 我的皮肤/文件夹已经修改了css for new mage admin和template文件夹只有page / head.phtml来加载额外的css。

请有人帮助我,为什么我们无法为管理员/目录用户看到相同的模板。

2 个答案:

答案 0 :(得分:2)

这不是为后台使用自定义主题的正确方法。

Magento已经实现了这一点。您只需将它放在任何config.xml(app / etc或任何自定义模块中)中。

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

有了这个,Magento将在app / design / adminhtml / default / custom中寻找你的设计模板,在app / design / adminhtml / default / default上进行故障转移,你的设计资源在skin / adminhtml / default / custom中皮肤上的故障转移/ adminhtml / default / default

答案 1 :(得分:0)

固定它!

问题不在系统&gt;配置&gt;设计但实际上系统&gt;设计我发现系统&gt;设计已将其设置为默认/购​​物者,并且没有时间范围。以下链接帮助我得出结论。

http://www.magentocommerce.com/boards/viewthread/197908/

你应该系统&gt;设计用于临时主题更改,但我的网站设置时没有时间范围,因此始终覆盖系统&gt;中的设置配置&gt;设计