2014-10-16 54 views
1

最初我是新手到magento。所以請幫助我學習magento。我創建了一個名爲「卡片憑證」的自定義模塊。我需要啓用或禁用模塊表單adminpanel。所以我創建了系統文件如何做自定義模塊啓用/禁用管理不工作 - Magento

我的app/code/community/card/voucher/etc/system.xml。代碼如下所示

<config> 
<tabs> 
    <myconf translate="label"> 
     <label>card voucher</label> 
     <sort_order>150</sort_order> 
    </myconf> 
</tabs> 
<sections> 
    <tab1 translate="label" module="adminhtml"> 
     <label>Enable/Disable</label> 
     <tab>myconf</tab> 
     <sort_order>10</sort_order> 
     <show_in_default>1</show_in_default> 
     <show_in_website>1</show_in_website> 
     <show_in_store>1</show_in_store> 
     <groups> 
      <general translate="label comment"> 
       <label>General</label> 
       <sort_order>50</sort_order> 
       <show_in_default>1</show_in_default> 
       <show_in_website>1</show_in_website> 
       <show_in_store>1</show_in_store> 
       <comment><![CDATA[This is a <strong>card voucher</strong> Extension used for checking voucher code.<br />You can simply enable disable this extension here. ]]></comment> 
       <fields> 

        <active translate="label comment"> 
         <label>Enable/Disable</label> 
         <frontend_type>select</frontend_type> 
         <sort_order>54</sort_order> 
         <source_model>adminhtml/system_config_source_enabledisable</source_model> 
         <show_in_default>1</show_in_default> 
         <show_in_website>1</show_in_website> 
         <show_in_store>1</show_in_store> 
        </active> 
       </fields> 
      </general> 
     </groups> 
    </tab1> 
</sections> 

然後我禁用了模塊,但仍住在我的網站。我認爲這個代碼僅僅足以建立這個功能。

請儘快

感謝

+0

從應用/ etc/modules中禁用模塊然後清除緩存和管理員註銷。這應該在那之後起作用。 – Chiragit007 2014-10-16 12:54:48

+0

Ok @ Chiragit007,但這是一種手動方式,是否有任何可能通過管理面板進行啓用/禁用過程。 – 2014-10-16 13:16:02

+0

是去系統 - >配置 - >高級部分。在那裏找到你的模塊,並將其設置爲「禁用」。不要忘記最後保存設置。 – Chiragit007 2014-10-16 13:17:13

回答

1

幫我通常你會希望禁用模塊的功能,而不是從系統配置模塊本身。

這個模塊到底做了什麼?

在你的代碼

if(Mage::getStoreConfig('sectionName/groupName/active')){ 
    // run your code 

} 
+0

Thanx @ P.S,最初使用這個模塊是檢查代金券代碼的狀態(知道它是否過期)。然後給出我需要粘貼到模塊上的代碼。請具體說明。謝謝:) – 2014-10-17 07:15:45

+0

@ P.S,Indexcontroller.php? – 2014-10-17 07:30:38

+0

你可以爲你的indexController.php添加代碼嗎?你需要做的就是圍繞if語句包裝代碼,並決定當模塊禁用時你想要顯示的內容 – 2014-10-17 11:49:25

相關問題