Magento xml module layout boot order
I have a custom extension that includes jQuery through an XML layout like this:
<reference name="head">
<action method="addJs"><script>jquery/jquery-1.8.1.min.js</script></action>
</reference>
Other extensions that use jQuery should be loaded after my module, so jQuery stays on top.
By default, Magento loads everything alphabetically. Is there a way to specify sort order for extensions?
One way is to override page.xmlin my topic and manually include jQuery in my head, or I can configure each user module to depend on the module that I want on top, for example:
<depends>
<Package_JQueryLib />
</depends>
Any other recommendations?
Edit
I thought I could override and change the method to enable sorting or adding files to the head. Mage_Page_Block_Html_Head addItem()
<depends /> node - - xpath , .
, page/html_head, - , , , , .
- <update> XML, <update /> . , jQuery .
<?xml version="1.0" encoding="UTF-8"?>
<layout>
<default>
<update handle="add_jquery_first" />
</default>
<add_jquery_first>
<action method="addJs" block="head">
<file>jquery/jquery-1.8.1.min.js</file>
</action>
<!-- or
<reference name="head">
<action method="addJs">
<file>jquery/jquery-1.8.1.min.js</file>
</action>
</reference>
-->
</add_jquery_first>
</layout>
: http://pastebin.com/tMUnWBWR
xml addJs sort_order, , js.
xml :
<action method="addJs">
<script>js/script.js</script>
<params/>
<sort_order>0</sort_order>
</action>
Magento downloads configuration files from the / etc / modules application in alphabetical order in the file app / code / core / Mage / Core / Model / Config.php in the protected method _getDeclaredModuleFiles ()
It is reported that Mage_All.xml will be loaded first, then all Magento configuration files (starting with Mage_), and finally custom modules in alphabetical order.
So, here's a small but dirty trick - name your namespace as AaaPackagename. The name starts with numbers, it will also do the trick: 1Packagename or 000Packagename