开发者

addItem only to Magento cms_page via local.xml can't use theme?

开发者 https://www.devze.com 2023-04-03 02:34 出处:网络
Magento doesn\'t want to look in my theme folder for these JS files when I use this code in local.xml

Magento doesn't want to look in my theme folder for these JS files when I use this code in local.xml

<!-- /app/design/frontend/my-theme/default/layout/local.xml -->
<xml>
  <cms_page>
    <reference name="head">
      <action method="addItem"><type>skin_js<开发者_C百科;/type><name>my.js</name><params/></action>
    </reference>
   </cms_page>
</xml>

This results in

<head>
    <script src="http://example.com/skin/frontend/base/default/my.js" />
</head>

whereas if I where to put the same XML code within the "default" xml tag it loads correctly. i.e....

<!-- /app/design/frontend/my-theme/default/layout/local.xml -->
<xml>
  <default>
    <reference name="head">
      <action method="addItem"><type>skin_js</type><name>my.js</name><params/></action>
    </reference>
  </default>
</xml>

loads...

<head>
    <script src="http://example.com/skin/frontend/MYTHEME/default/my.js" />
</head>

    <!-- Emphasis Added -->

The problem is that I only want to load this script for cms_pages. Is this impossible?

Using Magento 1.6 ~ The and yes, I've cleared the cache ;)

Oh, and my design configuration ( admin > configuration > design ) has "package" set to "my-theme", and the "default" set to "default"


The reason it ends up using the wrong URL when loading CMS pages is likely that you have a custom theme set on that CMS page.

The custom theme you define on a per-page level overrides the normal theme when the CMS page is rendered.

Check your CMS page settings under the custom design section.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号