?-腾讯云开发者社区-腾讯云">
在Magento安装中,我尝试将xml插入到主页的布局更新XML中。我已经有一些xml在那里工作,但我想添加一个jQuery脚本来运行我的幻灯片。我将它放在page.xml中(并计划在某个时候将它移到我的local.xml中),它在那里工作,但它破坏了产品页面上的Add to cart。因此,我想我应该合并到主页上,并将其放入布局更新XML中。由于某些原因,它没有通过。
<reference name="head">
<action method="addJs"><script>jquery/jquery-1.7.1.noConflict.min.js</script></action>
<action method="addJs"><script>folder/slider.js</script></action>
</reference>
你知道为什么它可以在我的page.xml中工作,而不是在这里吗?
下面是page.xml中的嵌套思想
<default translate="label" module="page">
<label>All Pages</label>
<block type="page/html" name="root" output="toHtml" template="page/3columns.phtml">
<block type="page/html_head" name="head" as="head">
<action method="addJs"><script>prototype/prototype.js</script></action>
发布于 2012-02-12 15:51:41
您可以执行以下操作:
将javascript添加到local.xml
<layout version="0.1.0">
<default>
<reference name="head">
<action method="addJs"><script>jquery/jquery-1.7.1.min.js</script></action>
<action method="addJs"><script>jquery/carouFredSel.js</script></action>
</reference>
</default>
</layout>
然后制作一个自定义主页模板(从1column.phtml参考),选择此模板从内容管理系统的主页。
将以下内容放入主页的"XML布局更新“部分的”设计“选项卡。这是我的设置,我从主页上删除了整个原型脚本是因为我不想要。
<reference name="head">
<action method="removeItem"><type>js</type><script>prototype/prototype.js</script></action>
<action method="removeItem"><type>js</type><script>prototype/validation.js</script></action>
<action method="removeItem"><type>js</type><name>scriptaculous/builder.js</name><params/></action>
<action method="removeItem"><type>js</type><name>scriptaculous/effects.js</name><params/></action>
<action method="removeItem"><type>js</type><name>scriptaculous/dragdrop.js</name><params/></action>
<action method="removeItem"><type>js</type><name>scriptaculous/controls.js</name><params/></action>
<action method="removeItem"><type>js</type><name>scriptaculous/slider.js</name><params/></action>
<action method="removeItem"><type>js</type><name>lib/ccard.js</name><params/></action>
<action method="removeItem"><type>js</type><name>varien/menu.js</name><params/></action>
<action method="removeItem"><type>js</type><name>varien/js.js</name><params/></action>
<action method="removeItem"><type>js</type><name>mage/translate.js</name><params/></action>
<action method="removeItem"><type>js</type><name>varien/form.js</name><params/></action>
<action method="removeItem"><type>skin_js</type><script>js/prototype.formalize.min.js</script></action>
<action method="removeItem"><type>skin_css</type><name>css/formalize.css</name><params/></action>
此外,不要创建特定的noConflict页面,只需将运行良好的jQuery脚本放在末尾即可。
举个例子,下面是我的:
jQuery&&define("jquery",[],function(){return f})})(window);var $jQuery = jQuery.noConflict();
另外,yu应该在js
根目录下创建jquery
文件夹,而不是在皮肤文件夹js
目录下。
https://stackoverflow.com/questions/9246000
复制相似问题