Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <action method="addJs"><!-- this will be shown second -->
- <script>prototype/javascript1.js</script>
- <params><![CDATA[name="js002_second"]]></params>
- </action>
- <action method="addJs"><!-- this will be shown first -->
- <script>prototype/javascript2.js</script>
- <params><![CDATA[name="js001_first"]]></params>
- </action>
- <reference name="head">
- <block type="core/template" name="fancy" as="fancy" template="fancybox/fancybox.phtml" />
- </reference>
- <script type="text/javascript" src="<?php echo Mage::getBaseUrl('js').'/fancybox.js'?>"></script>
- app/etc/modules/Company_ReorderAssets.xml
- <?xml version="1.0"?>
- <config>
- <modules>
- <Company_ReorderAssets>
- <active>true</active>
- <codePool>local</codePool>
- </Company_ReorderAssets>
- </modules>
- </config>
- <?xml version="1.0"?>
- <config>
- <modules>
- <Company_ReorderAssets>
- <version>1.0.0</version>
- </Company_ReorderAssets>
- </modules>
- <global>
- <blocks>
- <class>Company_ReorderAssets_Block</class>
- <page>
- <rewrite>
- <html_head>Company_ReorderAssets_Block_Page_Html_Head</html_head>
- </rewrite>
- </page>
- </blocks>
- </global>
- </config>
- <?php
- class Company_ReorderAssets_Block_Page_Html_Head extends Mage_Page_Block_Html_Head {
- public function addItemFirst($type, $name, $params = null, $if = null, $cond = null) {
- if ($type === 'skin_css' && empty($params)) {
- $params = 'media="all"';
- }
- $firstElement = array();
- $firstElement[$type . '/' . $name] = array(
- 'type' => $type,
- 'name' => $name,
- 'params' => $params,
- 'if' => $if,
- 'cond' => $cond,
- );
- $this->_data['items'] = array_merge($firstElement, $this->_data['items']);
- return $this;
- }
- public function addItemAfter($after, $type, $name, $params = null, $if = null, $cond = null) {
- if ($type === 'skin_css' && empty($params)) {
- $params = 'media="all"';
- }
- $firstElement = array();
- $firstElement[$type . '/' . $name] = array(
- 'type' => $type,
- 'name' => $name,
- 'params' => $params,
- 'if' => $if,
- 'cond' => $cond,
- );
- if (array_key_exists($after, $this->_data['items'])){
- $pos = 1;
- foreach ($this->_data['items'] as $key => $options){
- if ($key == $after) :
- break;
- endif;
- $pos +=1;
- }
- array_splice($this->_data['items'], $pos, 0, $firstElement);
- }
- return $this;
- }
- }
- <?xml version="1.0"?>
- <layout version="0.1.0">
- <default>
- <reference name="head">
- <action method="addItemFirst"><type>skin_js</type><script>js/jquery.js</script></action>
- <action method="addItemAfter">
- <after>skin_js/js/jquery.js</after>
- <type>skin_js</type>
- <script>custom_folder/javascript.js</script>
- </action>
- <action method="addItemAfter">
- <after>skin_js/js/jquery.js</after>
- <type>skin_js</type>
- <script>custom_folder/another_javascript.js</script>
- </action>
- </reference>
- </default>
- </layout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement