我如何在Magento产品页面中放置一个js文件

时间:2016-07-07 08:35:13

标签: xml magento

我制作了一个magento主题,并在文件local.xml

中包含以下代码

CODE XML:

<catalog_product_view>
            <reference name="root">
                <action method="setTemplate">
                    <template>page/1column.phtml</template>
                </action>
            </reference>
            <reference name="head">
                <action method="addItem">
                    <type>skin_js</type>
                    <name>js/jquery.prettyPhoto.js</name>
                </action>
                <action method="addCss">
                    <stylesheet>css/prettyPhoto.css</stylesheet>
                </action>
            </reference>
</catalog_product_view>

当我运行时,此代码未添加到js和css文件的头文件中

如果我进入文件base/default/layout/catalog.xml并添加以下代码。

<reference name="head">
            <action method="addJs"><script>varien/product.js</script></action>
            <action method="addJs"><script>varien/configurable.js</script></action>

            <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
            <action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
            <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
            <action method="addItem">
                <type>skin_js</type>
                <name>js/jquery.prettyPhoto.js</name>
            </action>
            <action method="addCss">
                <stylesheet>css/prettyPhoto.css</stylesheet>
            </action>
</reference>

你能告诉我这是不起作用的原因吗?

提前致谢!

0 个答案:

没有答案