我已经知道如何通过转到系统>配置>高级并<active>false</active>
在 etc/modules 中设置来禁用系统配置中的模块输出。我想知道的是如何使用我使用 system.xml 创建的自定义选项卡禁用模块。
问问题
1533 次
3 回答
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;
}
于 2017-07-26T05:47:13.787 回答
0
您可以在 system.xml 中添加新的启用/禁用字段,并在您的模块执行任何代码之前检查此字段值,如果启用则执行否则不执行,这样就可以了。
于 2017-07-26T04:41:11.227 回答
0
你必须在你的 xml 文件中使用ifconfig
例如,您在 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 如果您的模块已启用,则它将显示,否则将不会显示..!
于 2017-07-26T05:40:49.490 回答