Reputation: 4378
So I've done some layouts that I want to use and I was thinking that setting this in your local.xml file would fix this for every page. Like this
<default>
<reference name="root">
<action method="setTemplate">
<template>page/mytheme.phtml</template>
</action>
</reference>
</default>
This however doesn't do anything. Instead if I go
...<customer_account_forgotpassword>
<reference name="root">
<action method="setTemplate"><template>page/mytheme.phtml</template></action>
</reference>
</customer_account_forgotpassword>
<customer_account_confirmation>
<reference name="root">
<action method="setTemplate"><template>page/mytheme.phtml</template></action>
</reference>
</customer_account_confirmation>...
and so on for every specific place it gets changed on those specific pages. Am I thinking wrong or this the only way to do it?
Upvotes: 5
Views: 9393
Reputation: 2533
I had similar problem and thought it might save someones time.
Was trying to set 1column
layout to cms pages. None of the solutions worked until I realized:
CMS page template is set from Admin CMS > Pages > Design > Layout
, not local.xml.
If you set template for <default>
handle in local.xml
, it does not help, because this will be overrided by layout handle choosen from Admin pages for each specific CMS page.
Upvotes: 0
Reputation: 78991
Actually, you are the on the right track. You just didn't specify the request on your local.xml
. You should also include the request you are overriding.
Here is a example code of local.xml
<layout>
<default>
....
</default>
<!-- Update Configuration for this request specially -->
<customer_account_confirmation>
<reference name="root">
<action method="setTemplate"><template>page/mytheme.phtml</template></action>
</reference>
</customer_account_confirmation>
</layout>
This much configuration is enough to do, what you need.
Upvotes: 2
Reputation: 166066
The problem you're (probably) running into is that something comes along later and sets the template for the root block again, overriding your change.
More recent versions of Magento (1.4somethingish) introduced a way to prevent this from happening. If you look in page.xml
, you'll see a handle like this
<page_one_column translate="label">
<label>All One-Column Layout Pages</label>
<reference name="root">
<action method="setTemplate"><template>page/1column.phtml</template></action>
<!-- Mark root page block that template is applied -->
<action method="setIsHandle"><applied>1</applied></action>
</reference>
</page_one_column>
If the page_one_column
handle gets applied to your request, or you manually apply it with
<update handle="page_one_column" />
Magento will change the template and call the setIsHandle
method on the block.
<action method="setIsHandle"><applied>1</applied></action>
There's code in Magento that will look for the IsHandle property, and if it's true, further calls to setTemplate
will be ignored. (that's over-simplifying things a bit, but is more or less true)
Try something like
<default>
<reference name="root">
<action method="setTemplate">
<template>page/mytheme.phtml</template>
</action>
<action method="setIsHandle">
<applied>1</applied>
</action>
</reference>
</default>
And see if that helps.
Keep in mind this is one of those grey areas where it's not clear if third party developers are supposed to tread. Also, changing the template for all pages may have un-desirable effect on parts of the site that expect to be in a certain template.
Upvotes: 11
Reputation: 1321
Yes, it seems that you have to add it to some of the individual handles themselves. That's because the <default>
handle is the first one that is loaded. The <customer_account_forgotpassword>
handle is only read later. If you check the file design/frontend/base/default/layout/customer.xml
you will see that this very same handle sets a different template than the <default>
one.
Look at this example of the order that the layout handles are read by Magento for the "Forgot Password" page:
1. default
2. STORE_default
3. THEME_frontend_default_babel
4. customer_account_forgotpassword
5. customer_logged_out
There you can see why the <default>
handle's template setting is overridden.
I recommend you use the Layout Viewer module for Magento by Alan Storm: http://alanstorm.com/layouts_blocks_and_templates
Upvotes: 1