I\'m sure I saw before somewhere, specifying a value for xml ifconfig statements (as default is just boolean). Anyways, disabling modules in the admin doesn\'t actually work
This fits in well with something (self-link) I've been working on.
You can't do exactly what you want without a class rewrite to change the behavior of ifconfig
. Here's the code that implements the ifconfig
feature.
File: app/code/core/Mage/Core/Model/Layout.php
protected function _generateAction($node, $parent)
{
if (isset($node['ifconfig']) && ($configPath = (string)$node['ifconfig'])) {
if (!Mage::getStoreConfigFlag($configPath)) {
return $this;
}
}
If the presence of an ifconfig is detected and the config value returns true, the action method will not be called. You could rewrite _generateAction
and implement your own conditional, but then the standard burdens of maintaining a rewrite fall you on.
A better approach would be to use a helper method in your action paramater. Something like this
<action method="setTemplate">
<template helper="mymodule/myhelper/switchTemplateIf"/>
</action>
will call setTemplate with the results of a call to
Mage::helper('mymodule/myhelper')->switchTemplateIf();
Implement your custom logic in switchTemplateIf
that either keeps the template or changes it and you'll be good to go.
You could create a separate enable setting using nothing but your module's system.xml
.
<config>
<sections>
<advanced>
<groups>
<YOURMODULE>
<fields>
<enable>
<label>YOUR MODULE</label>
<frontend_type>select</frontend_type>
<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>
</enable>
</fields>
</YOURMODULE>
</groups>
</advanced>
</sections>
</config>
Then use the new setting in the layout file:
<action method="setTemplate" ifconfig="advanced/YOURMODULE/enable">
<template>mytemplate.phtml</template>
</action>