0

I'm trying to set a template for all CMS pages on my site but I can't manage to do it, though the layout handle is detected :

<cms_page>
    <reference name="root">
        <action method="setTemplate"><template>page/cms_page.phtml</template></action>
        <action method="addBodyClass"><class>test-class</class></action>
        <remove name="birdietown_homepage_mini_slider_our_brands"/>
        <remove name="birdietown_homepage_mini_slider_our_products"/>
        <remove name="birdietown_homepage_daclub"/>
    </reference>
</cms_page>

this layout XML node is detected, because the test-class is added to my page output, but the template is still 1column.phtml. This handle is in local.xml

1
  • Please try <cms_index_defaultindex> <reference name="root"> <action method="setTemplate"><template>page/cms_page.phtml</template></action> </reference> </cms_index_defaultindex>
    – Abdul
    Nov 5, 2015 at 9:25

2 Answers 2

2

you cannot set the template via layout xmls for the cms pages.
I mean, you can, but it has no effect because what you set in the xml is overwritten later by the selection you make in the Layout dropdown for each page.
The cms_page handle is loaded here but the root template set from the UI is loaded lower in the code.
You can try to rewrite the method linked above and remove the applying of the root template.
But I don't think that's a good idea.
I would create a new page layout. Here is how you can do that Then assign all the CMS pages to that layout using the Layout field from the admin page edit screen.

3
  • Thanks for the input, i understand the issue a lot better now i think :) I managed to integrate the new template in the page layout list in backoffice, i'm now looking for a way to set my new page layout as default value for the option when creating a new page in admin
    – Thomon
    Nov 5, 2015 at 9:48
  • @Thomon. For that, you can rewrite the method Mage_Adminhtml_Cms_PageController::editAction and add a verification. If there is no page id passed in the request (you are on add page) then set your new layout to the page model. So for this if statement add an else branch that looks like this ` } else { if (!$id) {$model->setRootTemplate('your_page_layout_handle_here')}}`. (I didn't test the code but it seams like the way to go)
    – Marius
    Nov 5, 2015 at 10:03
  • Thanks a lot for the clue, i didn't manage to get the override to work at the moment but i can go forward in my project now that my CMs pages can have the right template :)
    – Thomon
    Nov 5, 2015 at 10:21
1

In Magento pages are set based on page_one_column, page_two_columns_left, page_two_columns_right and page_three_columns

You can check it in page.xml file. You will need to create new cms page layout and can able to assign it from cms pages in admin

Check this link for how to add new cms page layout in Magento.

0

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.