我已經知道如何通過進入系統>配置>高級並在etc/modules中設置<active>false</active>
來禁用系統配置中的模塊輸出。我想知道的是如何使用我使用system.xml創建的自定義選項卡禁用模塊。在magento中使用system.xml在magento中禁用/啓用模塊
0
A
回答
1
將此代碼添加到您的system.xml
<fields>
<enable translate="label">
<label>Enable</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<sort_order>0</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
<comment>enable/disable the module</comment>
</enable>
</fields>
並在代碼中檢查這一點:在該模塊中的第一個動作之前(這可能是在你的cron.php or observer.php or indexcontroller
)
$isenabled = Mage::getStoreConfig('section_name/group_name/enable');
if (!$isenabled) {
return;
}
0
您可以在system.xml中添加新的啓用/禁用字段,並在模塊執行任何代碼之前檢查該字段值(如果啓用則執行,否則執行),這樣可以。
0
,你必須使用使用ifconfig在XML文件中
例如您在您的system.xml
<enable translate="label">
<label>enable</label>
<frontend_type>select</frontend_type>
<source_model>adminhtml/system_config_source_yesno</source_model>
<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>
而且在XML文件中的字段
<block class="your Blockname" name="name of field" ifconfig="sectionname/groupname/enable">
使用if config如果你的模塊是啓用然後它會顯示,否則它不會顯示..!
相關問題
- 1. 禁用模塊輸出Magento
- 2. 在模塊中禁用核心magento模塊config.xml
- 3. 如何在system.xml中設置默認值enable啓用組值magento?
- 4. 在Magento中禁用客戶
- 5. Magento system.xml組multiselect
- 6. 完全禁用模塊 - Magento 1.9
- 7. 在某些magento主題中禁用某個模塊
- 8. 確定是否啓用Magento模塊
- 9. Magento 1.7 - 覆蓋system.xml
- 10. 如何在Magento的網站啓用或禁用的Etag在Magento的網站
- 11. 如何在magento中禁用色板
- 12. 如何在Magento中爲system.xml中的文本框使用<source_model>?
- 13. 在Grid中爲Magento中的自定義管理模塊禁用複選框
- 14. 在magento 1.9上啓用CAPTCHA
- 15. 如何在Magento模塊中使用php設置元標記?
- 16. 如何在magento 1.9模塊中使用cURL
- 17. 如何使用模塊在magento admin中創建子菜單
- 18. 讓2個模塊在magento中使用相同的名字
- 19. 在magento中啓用分層導航
- 20. 在magento中默認啓用新產品
- 21. 我在Magento的檢查啓用模塊不工作
- 22. Magento的模塊示出了如在前端檢查時啓用
- 23. 如何做自定義模塊啓用/禁用管理不工作 - Magento
- 24. 如何禁用滑塊的Magento緩存
- 25. Magento禁用備份
- 26. 我的第三方希望啓用WSI模塊,而其他方希望它在magento中禁用
- 27. 如何使用Magento中的getUrl()引用另一個模塊?
- 28. 如何在Magento中創建模塊
- 29. Magento的:在local.xml中更改塊模板
- 30. 如何在Magento中安裝模塊?
我建議'Mage :: getStoreConfigFlag',因爲它返回'boolean'值。 – sv3n
@ sv3n它們唯一的區別是,getStoreConfig()將返回精確值,而getStoreConfigFlag()如其名稱所示,返回布爾值true或false。這兩種方法發送給我們Mage_Core_Model_Store :: getConfig() – NID
我知道......在我看來'Mage :: getStoreConfig'應該用於你想得到確切值的所有字段。對於所有其他(yes/no或啓用/禁用),我會使用'Mage :: getStoreConfigFlag',因爲'if(0)'不完全等於'if(false)'。仍然正確的答案:) – sv3n