Magento Themes and Magento Extensions

Magento: Custom Page Templates in CMS Layout Dropdown

Share

Creating new page templates is as easy as duplicating and editing the files in /template/page/. However, you can add as many new ones as you want, but no new ones will show up in the Layout dropdown when selecting a template to use for a specific CMS page.

The solution: Create your own simple module to add your templates. This should only take you 5 minutes if you know what you are doing with custom modules.

Step 1: Create Your Module Config File

Create this file: /app/code/local/YOURMODS/CmsTemplates/etc/config.xml and put the following code in, modifying it to suit your templates:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<config>
    <global>
        <cms>
            <layouts>
                <cms_template_1>
                    <label>Home Page</label>
                    <template>page/2columns-right-home.phtml</template>
                </cms_template_1>
		<cms_template_2>
                    <label>Category Listing</label>
                    <template>page/category_listing.phtml</template>
                </cms_template_2>
		<cms_template_3>
                    <label>4 Column</label>
                    <template>page/4columns.phtml</template>
                </cms_template_3>
            </layouts>
        </cms>
    </global>
</config>

Step 2: Enable Your Module

Edit or create the following file: /app/etc/modules/YOURMODS_All.xml. Put the following code in that file:

1
2
3
4
5
6
7
8
<config>
    <modules>
	<yourmods_CmsTemplates>
            <active>true</active>
            <codePool>local</codePool>
        </yourmods_CmsTemplates>
    </modules>
</config>

Clear Magento’s cache if you don’t have caching turned off, and edit a CMS Page. You should now see your new templates listed in the Layout dropdown under the Custom Design tab.

Leave a Reply

You must be logged in to post a comment.