Is this if-else-condition possible in layout XML?
There is no "inverse directive" to ifconfig
. You can still have the name parameter calculated by a helper method like this:
XML:
<action method="addItem">
<type>js_css</type>
<name helper="helpername/helpermethod"/>
</action>
helpername
is the identifier that you usually pass to Mage::helper($name)
and helpermethod
the method you want to call.
In your module's helper class (pseudo code):
public function helpermethod()
{
if ($enabled) {
return 'module/app1.css';
} else {
return 'module/app2.css';
}
}
use this extension for extended config option
you can use condition
tag for tag
<action method="addItem" ifconfig="module/general/enable" condition="1">
<type>js_css</type>
<name>module/app.css</name>
</action>
<action method="addItem" ifconfig="module/general/enable" condition="0">
<type>js_css</type>
<name>module/app1.css</name>
</action>