在Magento中,如何使用page.xml文件在自定义的两列左页中添加js或css文件.
我在page.xml中使用以下代码:168行
<page_two_columns_left translate="label">
<label>All Two-Column Layout Pages (Left Column)</label>
**<reference name="head">
<action method="addJs"><script>sidebar_menu.js</script></action>
</reference>**
<reference name="root">
<action method="setTemplate"><template>page/2columns-left.phtml</template> </action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_two_columns_left>
Run Code Online (Sandbox Code Playgroud)
我可以将它放在2column-left.phtml中使用js/css,但我不认为这是方便的方式.我想使用xml添加.
实际上你的代码上有两个星号吗?如果没有,基本上你在那里做的是正确的.然而:
<handle>
<reference name="head">
<action method="addJs"><script>prototype/prototype.js</script></action> <!-- adds a js referencing to the /js directory -->
<action method="addCss"><stylesheet>css/custom.css</stylesheet></action> <!-- adds CSS looking at the skin/ directories ( in reverse order: base/default, default/default, default/yourtheme, yourpackage/yourtheme -->
<action method="addItem"><type>skin_js</type><name>js/custom_script.js</name><params/></action> <!-- adds a js at the skin/ directories in the same manner as the above addCss directive -->
</reference>
<handle>
Run Code Online (Sandbox Code Playgroud)
请注意,可以替换为default
,modulename_controller_action
例如catalog_cart_index
或在您的情况下,page_two_columns_left
如果您有自定义皮肤可以使用,最好local.xml
在内部修改app/design/frontend/yourpackage/yourtheme/layout/
.
请尽可能不要触摸目录page.xml
内部app/design/frontend/base/default/layout/
.
归档时间: |
|
查看次数: |
6219 次 |
最近记录: |