Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - Is it possible to specify multiple values for ifconfig?

I want to specify multiple values for ifconfig in layout xml.

<action method="setTemplate" ifconfig="mymodule/general/is_enabled">
    <template>mymodule/test.phtml</template>
</action>

Is is possible to add below two conditions for one action?

ifconfig="mymodule/general/is_enabled"
ifconfig="mymodule/frontend/can_show"

Any suggestions would be most welcome.

like image 244
Ankita P. Avatar asked Sep 18 '25 20:09

Ankita P.


1 Answers

You could use a helper method in your action parameter. Something like this

<action method="setTemplate">
    <template helper="mymodule/myhelper/canShowIf"/>
</action>

will call setTemplate with the results of a call to

Mage::helper('mymodule/myhelper')->canShowIf();

And the following in your modules default helper:

public function canShowIf()
{
    if($displayOnly = Mage::getStoreConfig('mymodule/general/is_enabled') == true)

    // Do Something

    }else if($displayOnly = Mage::getStoreConfig('mymodule/frontend/can_show') == true)         {

    // Do Something Else

   }
    return $displayOnly;
}

Implement your custom logic in canShowIf.

like image 60
Slimshadddyyy Avatar answered Sep 20 '25 12:09

Slimshadddyyy