2012-03-07 60 views
1

我有一個Observer類,我總是用它來設置新的magento模板。Magento Admin自定義主題不起作用

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

我有這個。它適用於安裝時創建的主管理員用戶。

現在我們有許多管理員用戶將能夠登錄和添加products.But由於某種原因,它仍然顯示magento默認模板/皮膚,而不是選擇自定義模板(仍然在主管理員用戶誰可以訪問所有模塊/配置)。

因此,爲了使目錄用戶也看到相同的模板,我應該需要在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只有頁/ head.phtml加載額外的CSS。

請有人可以幫助我爲什麼無法看到管理員/目錄用戶相同的模板。

+0

剛猜測,它可能與商店有關。你是否試圖指定商店ID? – 2012-03-07 12:18:22

+0

你好OSdave,問題是什麼問題? – Elamurugan 2012-03-08 14:41:21

+0

嗨Oğuz,甚至刪除條件檢查時沒有任何反應。查看我更新的代碼。 – Elamurugan 2012-03-08 14:42:55

回答

2

這不是爲您的後臺使用自定義主題的正確方法。

Magento已經實現了這一點。你只要把這個在您的任何config.xml中的(一個應用程序中的/ etc或您的任何自定義模塊。

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

有了這個,Magento的將查找在應用程序/設計你的設計模板/ adminhtml /默認/自定義與應用程序/設計故障切換/ adminhtml/default/default組和設計資源,皮膚/ adminhtml /默認/自定義與皮膚/ adminhtml /默認的故障切換/默認

0

定了!

問題不在系統>配置>設計但在fac t 系統>設計我發現系統>設計它設置爲默認/購​​物者,並沒有它的時間框架。以下鏈接幫助我達成了我的結論。

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

你都應該系統>設計臨時主題的變化,但我的網站了吧,沒有時間框架因此總是在系統>配置>設計覆蓋我的設置中設置