This fits nicely with something (self-link) I was working on.
You cannot do what you want without rewriting the class to change the behavior of ifconfig
. Here is the code that implements the ifconfig
function.
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 ifconfig is detected and the config value returns true, the action method will not be called. You can rewrite _generateAction
and implement your own conditional expression, but then the standard burden of rewriting support disputes you.
A better approach would be to use a helper method in your action parameter. Something like that
<action method="setTemplate"> <template helper="mymodule/myhelper/switchTemplateIf"/> </action>
will call setTemplate with call results
Mage::helper('mymodule/myhelper')->switchTemplateIf();
Embed your own logic in switchTemplateIf
, which will either save the template or change it, and you will be good to go.
source share