Reorder Magento JavaScript Includes (addJs)

前端 未结 7 1581
无人共我
无人共我 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:30

    I think that Barny Shergold's solution is the most correct, but the comment about avoiding changing core files is correct. To have the best of both worlds, you can implement Barny's solution in a module that extends the Mage_Page_Block_Html_Head class like so:

    Yourcompany/Layouthelper/etc/config.xml

    
    
        
            
                0.0.1
            
        
        
            
                
                    
                        Yourcompany_Layouthelper_Block_Html_Head
                    
                
            
        
    
    

    Yourcompany/Layouthelper/Block/Html/Head.php

    class Yourcompany_Layouthelper_Block_Html_Head extends Mage_Page_Block_Html_Head {
    
        public function replaceItem($type, $name, $replace) {
            $newArray = array();
    
            foreach($this->_data['items'] as $key => $value) {
                if($key == $type.'/'.$name) {
                    $newArray[$type . '/'. $replace] = array(
                    'type'   => $type,
                    'name'   => $replace,
                    'params' => $value['params'],
                    'if'     => $value['if'],
                    'cond'   => $value['cond']);
                } else {
                    $newArray[$key] = $value;
                }
            }
            $this->_data['items'] = $newArray;
            return $this;
        }
    }
    

提交回复
热议问题