2

I'm using Magento CE 1.9.2.2 and I thought I was getting the hang of using a local.xml file to add/remove/update items from layout files but I've gotten stuck trying to update the head css/js from page.xml.

If I make the changes directly to page.xml in my package then it works fine. But if I move the changes to my local.xml file and remove page.xml the changes in local.xml have no effect. My local.xml is located here:
app/design/frontend/{MY_PACKAGE}/default/template/layout/local.xml

Other changes in local.xml for different pages work fine.


The working code in my page.xml would look like this(only showing relevant code):

<?xml version="1.0"?>
<layout version="0.1.0">
    <default translate="label" module="page">
        <block type="page/html" name="root" output="toHtml" template="page/3columns.phtml">
            <block type="page/html_head" name="head" as="head">
                <action method="addCss"><stylesheet>css/style.css</stylesheet><params>media="screen"</params></action>
                <!--<action method="addJs"><script>scriptaculous/builder.js</script></action>-->
            </block>
        </block>
    </default>
</layout>


The code I'm using in local.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <default>
        <reference name="head">
            <action method="addCss"><stylesheet>css/style.css</stylesheet><params>media="screen"</params></action>
            <action method="removeItem"><type>js</type><name>scriptaculous/builder.js</name></action>
        </reference>
    </default>
</layout>


Am I missing something obvious here?

2

Replace your code in file local.xml

from

<?xml version="1.0" encoding="UTF-8"?>
<layout>
    <default>
        <reference name="head">
            <action method="addCss"><stylesheet>css/style.css</stylesheet><params>media="screen"</params></action>
            <action method="removeItem"><type>js</type><name>scriptaculous/builder.js</name></action>
        </reference>
    </default>
</layout>

To

<?xml version="1.0"?>
<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="addCss"><stylesheet>css/styles.css</stylesheet><params>media="screen"</params></action>
            <action method="removeItem"><type>js</type><name>scriptaculous/builder.js</name></action>
        </reference>
    </default>
</layout>

Note : Don't forget to clear your cache!

1
  • That fixed it - thanks! I'm really surprised adding a version attribute to layout, and removing the encoding attribute could have such an effect. – iamlolz Jan 7 '16 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.