1

I want to display 3 or more type of footer in my theme, but the condition via XML not working properly. If i select Footer Default ( condition 0 ) don't show anything, if i select Footer Type 1 ( condition 1 ) i see Footer Type 1. But if is select Footer Type 2, Footer Type 3, etc i see only Footer Type 1. The "condition" work only for 0 and 1, or for all value ( 0,1,2,3,4,etc ) ?

<action method="setTemplate" ifconfig="footer/footer_type" condition="0">
   <template>page/html/footer/footer_type_default.phtml</template>
</action>
<action method="setTemplate" ifconfig="footer/footer_type" condition="1">
   <template>page/html/footer_type_1.phtml</template>
</action>
<action method="setTemplate" ifconfig="footer/footer_type" condition="2">
   <template>page/html/footer_type_2.phtml</template>
</action>

New Helper/Data.php

<?php

    class ThemeAdmin_Helper_Data extends Mage_Core_Helper_Abstract
    {
        public function getTemplate()
            {
                $footerType = Mage::getStoreConfig('footer/footer_type');
                switch ($footerType) {
                    case 0:
                        return "page/html/footer_tp_1.phtml";
                        break;
                    case 1:
                        return "page/html/footer_tp_2.phtml";
                        break;
                    case 2:
                        return "page/html/footer_tp_3.phtml";
                        break;
                    default:
                        break;
                }

            }


    }

System.xml

<config>
    <tabs>
        <admin translate="label">
            <label>Admin Theme</label>
            <sort_order>00</sort_order>
        </admin>
    </tabs>
    <sections>
        <themeadmin translate="label">
            <label>Theme Admin</label>
            <tab>Admin</tab>
            <frontend_type>text</frontend_type>
            <sort_order>1000</sort_order>
            <show_in_default>1</show_in_default>
            <show_in_website>1</show_in_website>
            <show_in_store>1</show_in_store>

            <groups>

                    <footer translate="label" module="themeadmin">
                        <label>Footer</label>
                        <frontend_type>text</frontend_type>
                        <sort_order>02</sort_order>
                        <show_in_default>1</show_in_default>
                        <show_in_website>1</show_in_website>
                        <show_in_store>1</show_in_store>
                        <fields>

                            <footer_type translate="label">
                                <label>Footer Type</label>
                                <frontend_type>select</frontend_type>
                                <source_model>themeadmin/system_config_source_footer_select</source_model>
                                <sort_order>01</sort_order>
                                <show_in_default>1</show_in_default>
                                <show_in_website>1</show_in_website>
                                <show_in_store>1</show_in_store>
                            </footer_type>
                        <fields>
                   </footer>
             </groups>
        </themeadmin>
    </sections>
</config>

Config.xml :

<helpers>
    <themeadmin>
        <class>Admin_ThemeAdmin_Helper</class>
    </themeadmin>
</helpers>

1 Answer 1

5

The ifconfig statement only works with yes/no configuration fields.

On top of that I'm not aware of any condition statement to overcome the issue.

Here's the alternative:

<action method="setTemplate">
    <template helper="themeadmin/getTemplate"/>
</action>

In your module, create Helper/Data.php if not already created and add the following method:

public function getTemplate()
{
    $footerType = Mage::getStoreConfig('themeadmin/footer/footer_type');
    switch ($footerType) {
        case 0:
            return "page/html/footer/footer_type_default.phtml";
            break;
        case 1:
            return "page/html/footer_type_1.phtml";
            break;
        case 2:
            return "page/html/footer_type_2.phtml";
            break;
        default:
            break;
    }

}
5
  • sorry not work, i see this on frontend : Jun 2, 2016 at 12:35
  • @user3309614 works fine for me, please post your system.xml Jun 2, 2016 at 12:36
  • edited, new Helper/Data.php and System.xml Jun 2, 2016 at 12:52
  • @user3309614 post the full system.xml please, some tags are missing here. Please also post your helper definition under config.xml Jun 2, 2016 at 12:54
  • @user3309614 I've updated my solution so it'll work with your module Jun 2, 2016 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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