1

I'm trying to use the local.xml file to change the default template for my entire theme. I found this question but it's not working for me: How do I set a Magento page's template to the 2-column layout?

I am able to add a custom css file to the head of the page, so it seems that my local.xml is located in the correct place. app/design/frontend/mypackage/default/layout/local.xml

Here is my local.xml:

<?xml version="1.0"?>
<layout>
  <default>
    <reference name="head">
      <action method="addCss"><stylesheet>css/this_style_sheet_is_working.css></stylesheet></action>
    </reference>

    <reference name="root">
      <action method="setTemplate">
        <template>page/custom.phtml</template>
      </action>
    </reference>
  </default>
</layout>

How can I change the default template? Why is my local.xml able to load css but not change the layout file?

3 Answers 3

1

Your change could be overriden:

  1. in admin panel (Page Layout for CMS Page, Category Page or Product Page)
  2. by more specific handle ('default' handle is the most general)
1

The <default> handle is the most generic handle so more specific handles such as cms_index_index take precedence over this. In order to change all your files to use a default one you could look at adding the layout handles you want and then using the update handle to change them, such as:

<checkout_cart_index>
    <update handle="page_one_column "/>
 </checkout_cart_index>

Another alternative you could look at using an observer such as core_block_abstract_prepare_layout_before to manually assign a template, however i wouldn't recommend making all the pages the same template.

Hope this helps.

1

You cannot set the layout of the page in the <default> layout handle.
I mean, you can but your changes will most probably be overwritten by an other layout handle.
The default layout handle is usually loaded first and if you have an other layout handle after that that sets the page layout it will override the first one.
Also, for cms pages, the layout is set from the backend by selecting somethng from the dropdown Layout update.
This could also happen for products and categories pages.

Your Answer

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

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