5

Look at the below layout which is from "base/default/layout/contacts.xml".

<default>
    <reference name="footer_links">
        <action method="addLink" translate="label title" module="contacts" ifconfig="contacts/contacts/enabled">
            <label>Contact Us</label>
            <url>contacts</url>
            <title>Contact Us</title>
            <prepare>true</prepare>
        </action>
    </reference>
</default>

What I understand from above layout is: (please let me know if I am wrong about something)

  • The blocks will be added in to the "default" layout handle.
  • The block "footer_links" is being referred which is in "page.xml"

    <block type="page/template_links" name="footer_links" as="footer_links" template="page/template/links.phtml"/>
    
  • The "footer_links" has type: "page/template_links" which is calling the class "Mage_Page_Block_Template_Links".
  • The "action" layout element is calling a method addLink from "Mage_Page_Block_Template_Links" class.
  • The "translate" attribute is used for language specific changes.

What I want to understand is:

  • What does "module" and "ifconfig" attributes are used for in "action" layout element?

1 Answer 1

6

module defines the module which is used for the translation like Mage::helper(<module>)->__(<label>|<title>).

Magento has different files and modules for translation, there is a lot of documentation in the net and here on magento.se.

And ifconfig checks for a config setting, if this is true, the method is called.

So addLink is only called if Mage::getStoreConfig('contacts/contacts/enabled') evaluates to true. This configuration setting is set in the backend, I think under System > Configuration > ??? > Contact us(?). Have a look for it :-)

And to extend your statement:

  • The action layout element is calling a method addLink from "Mage_Page_Block_Template_Links" class.

Correct - if page/template_links wasn't rewritten.

4
  • I am not from PHP background. This is going from top of my head. I understood only the part which is after this line "And to extend your statement:". Where is this "contacts/contacts/enabled" ?
    – Mr_Green
    Sep 12, 2013 at 9:05
  • please atleast provide me a link :)
    – Mr_Green
    Sep 12, 2013 at 9:35
  • 1
    When you are not from PHP background, you are directly driving to hell. Magento is very complex. First learn PHP, then learn magento. Trust me :) Sep 12, 2013 at 9:56
  • 1
    No time for it :(.. Anyway thanks for your edit. I did understand the function of ifconfig :) but still I need to understand module.. (I can understand basics of PHP because I am from javascript background)
    – Mr_Green
    Sep 12, 2013 at 10:00

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.