0

I want to add another css file in the header on every page. In earlier versions, I would have

  1. Copied app/design/frontend/base/default/layouts/page.xml to app/design/frontend/my_package/my_theme/layouts/page.xml
  2. Add my action to the appropriate block in app/design/frontend/my_package/my_theme/layouts/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="addItem"><type>skin_css</type><name>css/my_header.css</name><params/><if>lt IE 8</if></action>
            </block>
            ...
        </block>
        ...
    </default>
    

From what I understand, the theme fallback in 1.9 is supposed to keep you from having to copy from the base .xml files. Following what I found at Layout updates in theme.xml, I attempted this using the following:

app/design/frontend/my_package/my_theme/etc/theme.xml:

<?xml version="1.0"?>
<theme>
    <parent>rwd/default</parent>    
    <layout>
        <updates>
            <default_page>
                <file>my_theme/page.xml</file>
            </default_page>
        </updates>
    </layout>
</theme>

app/design/frontend/my_package/my_theme/layout/page.xml:

<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="addItem"><type>skin_css</type><name>css/my_header.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
            </block>
        </block>
    </default>
</layout>

Doing this kills my theme as well as the RWD theme. What am I missing? I know I could just copy it as in previous versions. What's the right way to do this?

1 Answer 1

0

EDIT: You will need to change your file app/design/frontend/my_package/my_theme/layout/page.xml to app/design/frontend/my_package/my_theme/layout/themename.xml as page is already declared e.g in app/design/frontend/my_package/my_theme/etc/theme.xml

<?xml version="1.0"?>
<theme>
    <parent>rwd/default</parent>    
    <layout>
        <updates>
            <default_page>
                <file>my_theme/mytheme.xml</file>
            </default_page>
        </updates>
    </layout>
</theme>

When magento renders renders it merges all the layout.xml files, so if you have the same name such as page it will overwrite the other updates. You can read more here: http://magebase.com/magento-tutorials/digging-deeper-into-magentos-layout-xml-part-2/

Also make sure you don't redeclare the blocks you can just do the following:

<layout version="0.1.0">
    <default>
        <reference name="head">
            <action method="addItem"><type>skin_css</type><name>css/my_header.css</name><params/><if><![CDATA[<!--[if (gte IE 9) | (IEMobile)]><!-->]]></if></action>
        </reference>
    </default>
</layout>
3
  • Thank you. That makes a lot of sense. However, doing that still loads a blank page. If I remove my page.xml altogether, I get the page without styling. Nothing is getting logged either. Is there something I need to change in my theme.xml?
    – eisaacson
    Oct 29, 2015 at 15:47
  • Correction: there was something else going on. Without page.xml, the enterprise styles are still there.
    – eisaacson
    Oct 29, 2015 at 17:14
  • Just updated my answer.
    – rob3000
    Oct 31, 2015 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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