0

I was trying to add a phtml file via update xml for one of my custom module

am pasting my config.xml file here

<config>
  <frontend>
    <routers>
            <integer>
                <use>standard</use>
                <args>
                    <module>Foo_Bar</module>
                    <frontName>integer</frontName>
                </args>
            </integer>
        </routers>
        <layout>
            <updates>
                <integer>
                    <file>integer.xml</file>
                </integer>
            </updates>
        </layout>
  </frontend>
</config>

This works perfect for me.

I had learned that immediate node under the 'router' node is just an identifier.so i changed it to some other value and correspondingly i changed the immediate node under 'updates' also to the same value.but it was not working. then i thought my 'frontName' value should be the node under 'updates', and i changed accordingly. but again layout update was not working.

Queston: what should be the node under 'upates' node? 'frontName' value OR the same node under 'routers' OR both the nodes should match frontName value?

EDIT:

<config>
  <frontend>
    <routers>
            <integer>
                <use>standard</use>
                <args>
                    <module>Foo_Bar</module>
                    <frontName>integer</frontName>
                </args>
            </integer>
        </routers>
        <layout>
            <updates>
                <something>
                    <file>integer.xml</file>
                </something>
            </updates>
        </layout>
  </frontend>
</config>

This config also working perfect for me.

Am getting increasingly curious about the relations now

UPDATE:My layout updates are only working when my <frontName> value matches the node name immediately under <routes> node. But routes work properly if they are not same

Somebody please explain my problem.or is it not a problem?

  • None of those node names matter, as long as they are unique identifiers (unless you want to overwrite some core node). Why it didn't work in the first place? Either a typo or caching. – Daniel Sloof May 15 '13 at 8:24
  • @DanielSloof:Both the configs are working for me.its definitely not cache, as i cleared it from admin panel and folder.But i was wondering what is the relation between layout updates and routes. Thats y i posted this question – zamil May 15 '13 at 9:40
3

Unless you are executing an action in your module's controllers, there is no connection between the router configuration node and the layout file configuration node.

The only connection between router configuration and layout is the layout update handles for your module's controllers. If you were accessing your IndexController::indexAction(), the full action name layout handle would be <integer_index_index>. Change the arbitrary router configuration node to something else and you would need to update your layout XML. This is the main purpose of the frontName - it can be changed.

  • :thanks. but i find that if i want any layout updates to work with my custom module the immediate child node that follows the <routers> node should match the <frontName> node value. or at least it is working like that for me. But routing will work perfect regardless of above said point.please share some knowledge on this – zamil May 16 '13 at 4:56
  • "if i want any layout updates to work with my custom module the immediate child node that follows the <routers> node should match the <frontName> node value" - There is nothing in the code enforcing this. In fact, all of the core Enterprise modules do not follow this convention and they work fine. The only connection is that the node name at e.g. frontend/routers/[node name] is part of the full action name and therefore is "part" of layout update handles for your module. – benmarks May 16 '13 at 14:43
  • mee to was thinking like that. but for my two installations the above said rule came true,so that created some confusion on me.thats y i decided to put this question in the first place, any way i vl make another isntallation and try again.meanwhile i should say i am using CE 1.7 – zamil May 17 '13 at 9:02
0

In your layout file "integer.xml" file input the following...

<layout version="0.1.0">
<Bar_controllername_MethodName>
    <reference name="content">
        <block type="ModuleName/Blockname" name="" template="path to template file" />
    </reference>
</Bar_controllername_MethodName>
</layout>
0

Found it .

The full action name layout handle should be <nodeNameFollowingRoutersNode_controller_action>

routers and updates node does not have any relation

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.