In my theme I already use (in local.xml):
<reference name="top.links">
<action method="setTemplate"><template>page/html/header/links.phtml</template></action>
</reference>
Now I’m making a module where I want to change the template, hence making the module installable without any needs to modify the theme.
So almost same code from a module xml-file:
<reference name="top.links">
<action method="setTemplate"><template>sociallogin/header/links.phtml</template></action>
</reference>
Magento always pick the first one in local.xml
How can I override this?
You shouldn’t (although I’ll give you some possible ideas at the end of this post). Magento is designed such that code in
local.xml“wins” over code in an installable module file. The basic idea islocal.xmlis where a store owner goes to add layout updates that override module file updates. This is How The System Works™ and changing it would create more chaos than it would solve.That said, you might be able to work within the system if you put your code in a different layout handle. Handles are the node that surround the layout updates
The way Magento’s layout system works is:
defaulttag are run from module files, and then fromlocal.xml.catalog_category_vieware run from module files, and then fromlocal.xml.customer_logged_outare run from module files, and then fromlocal.xml.That is, there’s a handle order/specificity. Checkout the Layout tab of the Commerce Bug Demo store (after clicking debug) to see the handle order for a page. (disclaimer: Commerce Bug is a product I created and sell)
So, if your
local.xmlfile applied its updates indefaultand you really can’t rejigger this, then you could apply your module updates in a handle that came later.Good luck.