Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. <action method="addJs"><!-- this will be shown second -->
  2. <script>prototype/javascript1.js</script>
  3. <params><![CDATA[name="js002_second"]]></params>
  4. </action>
  5. <action method="addJs"><!-- this will be shown first -->
  6. <script>prototype/javascript2.js</script>
  7. <params><![CDATA[name="js001_first"]]></params>
  8. </action>
  9.  
  10. <reference name="head">
  11. <block type="core/template" name="fancy" as="fancy" template="fancybox/fancybox.phtml" />
  12. </reference>
  13.  
  14. <script type="text/javascript" src="<?php echo Mage::getBaseUrl('js').'/fancybox.js'?>"></script>
  15.  
  16. app/etc/modules/Company_ReorderAssets.xml
  17.  
  18. <?xml version="1.0"?>
  19.  
  20. <config>
  21.  
  22. <modules>
  23.  
  24. <Company_ReorderAssets>
  25.  
  26. <active>true</active>
  27.  
  28. <codePool>local</codePool>
  29.  
  30. </Company_ReorderAssets>
  31.  
  32. </modules>
  33.  
  34. </config>
  35.  
  36. <?xml version="1.0"?>
  37.  
  38. <config>
  39.  
  40. <modules>
  41.  
  42. <Company_ReorderAssets>
  43.  
  44. <version>1.0.0</version>
  45.  
  46. </Company_ReorderAssets>
  47.  
  48. </modules>
  49.  
  50. <global>
  51.  
  52. <blocks>
  53.  
  54. <class>Company_ReorderAssets_Block</class>
  55.  
  56. <page>
  57.  
  58. <rewrite>
  59.  
  60. <html_head>Company_ReorderAssets_Block_Page_Html_Head</html_head>
  61.  
  62. </rewrite>
  63.  
  64. </page>
  65.  
  66. </blocks>
  67.  
  68. </global>
  69.  
  70. </config>
  71.  
  72. <?php
  73.  
  74.  
  75.  
  76. class Company_ReorderAssets_Block_Page_Html_Head extends Mage_Page_Block_Html_Head {
  77.  
  78.  
  79.  
  80. public function addItemFirst($type, $name, $params = null, $if = null, $cond = null) {
  81.  
  82.  
  83.  
  84. if ($type === 'skin_css' && empty($params)) {
  85.  
  86. $params = 'media="all"';
  87.  
  88. }
  89.  
  90.  
  91.  
  92. $firstElement = array();
  93.  
  94. $firstElement[$type . '/' . $name] = array(
  95.  
  96. 'type' => $type,
  97.  
  98. 'name' => $name,
  99.  
  100. 'params' => $params,
  101.  
  102. 'if' => $if,
  103.  
  104. 'cond' => $cond,
  105.  
  106. );
  107.  
  108.  
  109.  
  110. $this->_data['items'] = array_merge($firstElement, $this->_data['items']);
  111.  
  112.  
  113.  
  114. return $this;
  115.  
  116.  
  117.  
  118. }
  119.  
  120.  
  121.  
  122. public function addItemAfter($after, $type, $name, $params = null, $if = null, $cond = null) {
  123.  
  124.  
  125.  
  126. if ($type === 'skin_css' && empty($params)) {
  127.  
  128. $params = 'media="all"';
  129.  
  130. }
  131.  
  132.  
  133.  
  134. $firstElement = array();
  135.  
  136. $firstElement[$type . '/' . $name] = array(
  137.  
  138. 'type' => $type,
  139.  
  140. 'name' => $name,
  141.  
  142. 'params' => $params,
  143.  
  144. 'if' => $if,
  145.  
  146. 'cond' => $cond,
  147.  
  148. );
  149.  
  150.  
  151.  
  152. if (array_key_exists($after, $this->_data['items'])){
  153.  
  154.  
  155.  
  156. $pos = 1;
  157.  
  158. foreach ($this->_data['items'] as $key => $options){
  159.  
  160. if ($key == $after) :
  161.  
  162. break;
  163.  
  164. endif;
  165.  
  166. $pos +=1;
  167.  
  168. }
  169.  
  170.  
  171.  
  172. array_splice($this->_data['items'], $pos, 0, $firstElement);
  173.  
  174.  
  175.  
  176. }
  177.  
  178.  
  179.  
  180. return $this;
  181.  
  182.  
  183.  
  184. }
  185. }
  186.  
  187. <?xml version="1.0"?>
  188.  
  189. <layout version="0.1.0">
  190.  
  191. <default>
  192.  
  193. <reference name="head">
  194.  
  195. <action method="addItemFirst"><type>skin_js</type><script>js/jquery.js</script></action>
  196.  
  197. <action method="addItemAfter">
  198.  
  199. <after>skin_js/js/jquery.js</after>
  200.  
  201. <type>skin_js</type>
  202.  
  203. <script>custom_folder/javascript.js</script>
  204.  
  205. </action>
  206.  
  207. <action method="addItemAfter">
  208.  
  209. <after>skin_js/js/jquery.js</after>
  210.  
  211. <type>skin_js</type>
  212.  
  213. <script>custom_folder/another_javascript.js</script>
  214.  
  215. </action>
  216.  
  217. </reference>
  218.  
  219. </default>
  220.  
  221. </layout>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement