Magento Themes and Magento Extensions

Magento – Nested ifconfig for better Layouts


By default, Magento allows you to use ifconfig in the following way:

10 <action method="addItem" ifconfig="path/to/config/status/enabled"><type>skin_js</type><name>js/script_one.js</name></action>

the javascript js/script_one.js will be included if path/to/config/status/enabled is true.
Unfortunately, Magento does not allow you to use the “else” block for ifconfig.

for example:
Let’s say, you want to implement the following logic:
if path/to/config/status/enabled is true
include the javacript js/script_one.js
include the javacript js/script_two.js

Thanks to Extended ifconfig extension by CODNITIVE it is now possible to use more conditions by following the syntax below:

10 <!--?xml version="1.0"?-->
11 <layoutupdate>
12 <catalog_product_view>
13 <reference name="head">
14 <action method="addItem" ifconfig="path/to/config/status/enabled" condition="1"><type>skin_js</type><name>js/script_one.js</name></action>
15 <action method="addItem" ifconfig="path/to/config/status/enabled" condition="0"><type>skin_js</type><name>js/script_two.js</name></action>
16 </reference>
17 </catalog_product_view>
18 </layoutupdate>

Comments are closed.