14

I have a category in my store that requires a totally different layout to the standard Magento layouts. So I created a new copy of the 1column.phtml and renamed it and made one small change to test.

Now the problem is that the custom layout is not showing up. I created a module (which is working as it is seen in the Admin > Config > Advanced overview).

My files and contents are as follows:

app/etc/modules/Test_Page.xml

    <?xml version="1.0"?>
<config>
    <modules>
        <Test_Page>
            <active>true</active>
            <codePool>community</codePool>
            <version>0.1.0</version>
            <depends>
                <Mage_Page />
            </depends>
        </Test_Page>
    </modules>
</config>

app/code/local/Test/Page/etc/config.xml

    <?xml version="1.0"?>
<config>
    <modules>
        <Test_Page>
            <version>0.1.0</version>
        </Test_Page>
    </modules>
    <global>
        <page>
            <layouts>
                <homepage module="page" translate="label">
                    <label>Homepage</label>
                    <template>page/home.phtml</template>
                    <layout_handle>homepage</layout_handle>
                </homepage>

                <!-- add more layouts here -->
            </layouts>
        </page>
    </global>
    <frontend>
        <layout>
            <updates>
                <Test_Page>
                    <file>test_page.xml</file>
                </Test_Page>
            </updates>
        </layout>
    </frontend>
</config>

app/design/frontend/test/default/layout/test_page.xml

    <?xml version="1.0"?> 
<layout>
    <homepage translate="label">
        <label>Home Page</label>
        <reference name="root">
            <action method="setTemplate"><template>page/home.phtml</template></action>
            <action method="setIsHandle"><applied>1</applied></action>
        </reference>
    </homepage> 
</layout>

I can't see anything I've screwed up, It's being read as a module but the custom layout is not being shown up :(

21

In order to make it appear in the layout dropdown you need to create a custom module (you can also add something in a core file but please don't do that). Let's name the extension Easylife_Layout. For this you need to create the following files: app/etc/modules/Easylife_Layout.xml - the declaration file

<?xml version="1.0"?>
<config>
    <modules>
        <Easylife_Layout>
            <active>true</active>
            <codePool>local</codePool>
            <depends>
                <Mage_Page />
            </depends>
        </Easylife_Layout>
    </modules>
</config>

app/code/local/Easylife/Layout/etc/config.xml - the configuration file

<?xml version="1.0"?> 
<config>
    <modules>
        <Easylife_Layout>
            <version>0.0.1</version>
        </Easylife_Layout>
    </modules>
    <global>
        <page>
            <layouts> 
                <lookbook module="page" translate="label">
                    <label>Lookbook</label>
                    <template>page/1column-lookbook.phtml</template>
                    <layout_handle>lookbook</layout_handle>
                </lookbook> 
            </layouts>
        </page>
    </global>
    <frontend>
        <layout>
            <updates>
                <easylife_layout>
                    <file>easylife_layout.xml</file>
                </easylife_layout>
            </updates>
        </layout>
    </frontend>
</config>

app/design/frontend/{interface}/{theme}/layout/easylife_layout.xml - the layout file

<?xml version="1.0"?> 
<layout>
    <lookbook translate="label">
        <label>Lookbook</label>
        <reference name="root">
            <action method="setTemplate"><template>page/1column-lookbook.phtml</template></action>
            <action method="setIsHandle"><applied>1</applied></action>
        </reference>
    </lookbook> 
</layout>

The last one is necessary in case you want to be able to reference your custom layout in layout files. Something like:

<update hande="lookbook" />

Clear the cache and...that's it. Le tme know if it works for you.

  • logging in and out did the trick for me after this – cyptus Apr 15 '16 at 11:08
6

There are two possibilities:

  1. You add a custom layout to your category and do this:

    <layout>
        <reference name="root">
            <action method="setTemplate"><template>page/1column-lookbook.phtml</template></action>
        </reference>
    </layout>
    
  2. You implement it as a page layout and add it to the config.xml in global/page/layouts/ but I don't know, how to do it exactly.

If you only need it once, you can stay with the first solution. But be careful. There are <action method="setIsHandle"><applied>1</applied></action> in the page.xml Sometimes this setting prevents the change of the template.

To do the first solution: Select your category, got to Custom Design and put everything inside the <layout /> node into the Custom Layout Update textarea, e.g.:

<reference name="root">
    <action method="setBackgroundGraphic">
        <background>two-pieces</background>
    </action>
    <action method="setTemplate">
    <template>page/2columns-right-highStep.phtml</template>
    </action>
    <action method="setIsHandle">
        <applied>1</applied>
    </action>
</reference>
  • Where would I have to stick the layout reference for the first one? I tried very similar code in layout.xml but had no idea what level to place it, i have references there for all category pages as default using <catalog_category_view> so i assumed i need something similar to add another option – Chris Morris Mar 5 '13 at 12:50
  • edited the answer – Fabian Blechschmidt Mar 5 '13 at 18:05

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.