简体   繁体   English

magento 自定义CMS页面添加javascript

[英]magento custom CMS page add javascript

i am following this howto to add a custom CMS page http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/0_-_theming_in_magento/adding_cms_layout_templates我正在按照此方法添加自定义 CMS 页面http://www.magentocommerce.com/wiki/4_-_themes_and_template_customization/0_-_theming_in_magento/adding_cms_layout_templates

the issue i am having is that i want to add a NivoSlider javascript just to this page and the only way to add it to the is to do it through the Admin -> CMS -> Pages and then change the Layout Update XML by adding the我遇到的问题是我想将 NivoSlider javascript 添加到此页面,将其添加到的唯一方法是通过 Admin -> CMS -> Pages 然后更改 Layout Update XML 添加

<reference name="head">
<action method="addJs">
<script>nivo-slider/jquery.nivo.slider.js</script>
</action>
<action method="addCss">
<script>css/nivo-slider.css
</script></action>
</reference>

is there a way to add the javascript on the filesystem rather then through the Admin -> CMS -> Pages -> Page -> Layout Update XML interface?有没有办法在文件系统上添加 javascript 而不是通过 Admin -> CMS -> Pages -> Page -> Layout Update XML 界面?

any advise much appreciated任何建议非常感谢

You can override page.xml in your layouts folder of your theme and add the script globally like,您可以在主题的布局文件夹中覆盖 page.xml 并全局添加脚本,例如,

<action method="addJs"><script>nivo-slider/jquery.nivo.slider.js</script></action>

You can just write the code directly to your CMS page in the backend as you would write it normally.您可以像往常一样将代码直接写入后端的 CMS 页面。 You can just use <style></style> and/or <script></script> tags and write your CMS site specific code into it.您可以只使用<style></style>和/或<script></script>标签并将您的 CMS 站点特定代码写入其中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM