`
hudeyong926
  • 浏览: 2016421 次
  • 来自: 武汉
社区版块
存档分类
最新评论

magento 添加 删除css js

 
阅读更多

在addJs、addCss的代码一般在page/html_head类型的block当中,Magento首先会将所有文件存储在$_data当中,最终通过getCssJsHtml函数解析成对应的html代码输出。


Head中支持add类型的方法有addCss、addJs、addCssIe、addJsIe、addLinkRel五种。

<reference name="head">
    <action method="addItem"><type>js_css</type><stylesheet>messagebox/blue/messagebox.css</stylesheet></action>
    <action method="addJs"><script>messagebox/jmessagebox.js</script><params>charset="utf-8"</params></action>
    <action method="addCss"><stylesheet>css/local.css</stylesheet></action>
    <action method="addJs"><script>scriptaculous/controls.js</script></action>
    <action method="addItem"><type>js</type><name>lib/ds-sleight.js</name><params/><if>lt IE 7</if></action>
</reference>

 通用的函数是addItem,需要指定type和name,如果有条件判断的话就放在if标签当中

 

如果需要删除某个js或者css,可以使用removeItem方法

<reference name="head">
<action method="removeItem"><type>skin_css</type><name>css/local.css</name></action>
</reference>

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics