Reorder Magento JavaScript Includes (addJs)

前端 未结 7 1587
无人共我
无人共我 2021-02-09 01:37

I\'ll keep this simple.... on my product pages I need to remove the prototype.js file and replace it with the latest version of prototype. So far using local.xml I have successf

7条回答
  •  情话喂你
    2021-02-09 02:19

    You can use the params element, with "data-group" HTML attribute in it, Magento will put items with "params" set after any items with no "params" set. You can use local.xml in your theme to ensure the order of these elements (I recommend to let Magento add its standard files first):

    
        
        
        
    
    
        
        
        
    
    
        
        
        
    
    
        
        
        
    
    
        
        
        
    
    
        
        
    
    

    The order in which elements with "params" set are rendered in only determined by the order in which actions are executed. Items are rendered grouped by the value of "params", so once group "js001" is defined by the first action (javascript2.js), successive actions with the same group name will append to that group, etc.

    In the example above, the order of rendering will be:

    • prototype/javascript5.js (no params, comes first)
    • prototype/javascript0.js (first created params group "js002")
    • prototype/javascript1.js (first created params group "js002")
    • prototype/javascript4.js (first created params group "js002")
    • prototype/javascript2.js (second created params group "js001")
    • prototype/javascript3.js (second created params group "js001")

    Items added using addItem addJs, addCss, etc, are threated in the same way, however they differ (and will be super-grouped accordingly) by type (see order below), with each group in super-groups internally ordered as explained above:

    • js
    • skin_js
    • js_css
    • skin_css

提交回复
热议问题