9

I want to display two different CSS

<action method="addItem" ifconfig="module/general/enable">
    <type>js_css</type>
    <name>module/app.css</name>
</action>

In XML we use ifconfig but I want to add two different CSS files like this

if (marketplace/general/enable == 1) {
     css-1
 } else {
     css-2 
 }

How can I do this?

16

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';
    }
}
| improve this answer | |
4

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>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.