Adding CMS Layout Templates

Last modified by sneha@zeon on Thu, October 21, 2010 07:09
Source|Old Revisions  

This is an old revision of the document!

You may find that you want to add additional layout template options to the CMS section that can be chosen when creating or editing a page in the admin interface. Unfortunately this requires digging into the core code a little, but the fix is very quick and should only take a couple of minutes.

Step 1: Backup

Make a backup of file we will be working with, it is located here:


Step 2: Create new template

Create a new template file in the following directory (you may chose to simply copy an existing template, such as 1column.phtml) and name is with an appropriate name (ie: home.phtml if that template will be used for your home page).


whereas YOUR_INTERFACE typically remains “default” and YOUR_THEME can also be “default” (please see Design-Guide about proper naming of themes and interfaces)

Step 3

Edit config.xml to add the new layout template to the available options.

On line ~175 find:

  1.         <cms>
  2.             <layouts>
  3.                 <empty>
  4.                     <label>Empty</label>
  5.                     <template>page/one-column.phtml</template>
  6.                 </empty>
  7.                 <one_column>
  8.                     <label>1 column</label>
  9.                     <template>page/1column.phtml</template>
  10.                 </one_column>
  11.                 <two_columns_left>
  12.                     <label>2 columns with left bar</label>
  13.                     <template>page/2columns-left.phtml</template>
  14.                 </two_columns_left>
  15.                 <two_columns_right>
  16.                     <label>2 columns with right bar</label>
  17.                     <template>page/2columns-right.phtml</template>
  18.                 </two_columns_right>
  19.                 <three_columns>
  20.                     <label>3 columns</label>
  21.                     <template>page/3columns.phtml</template>
  22.                 </three_columns>
  23.             </layouts>
  24.         </cms>

And insert the XML code for the new template where you want it to appear in the following format:

  1. <layout_description>
  2.     <label>Layout Name</label>
  3.     <template>page/template_name.phtml</template>
  4. </layout_description>

Here is an example of the finished code block after inserting a new template named home.phtml:

  1.         <cms>
  2.             <layouts>
  3.                 <empty>
  4.                     <label>Empty</label>
  5.                     <template>page/one-column.phtml</template>
  6.                 </empty>
  7.                 <home>
  8.                     <label>Home</label>
  9.                     <template>page/home.phtml</template>
  10.                 </home>
  11.                 <one_column>
  12.                     <label>1 column</label>
  13.                     <template>page/1column.phtml</template>
  14.                 </one_column>
  15.                 <two_columns_left>
  16.                     <label>2 columns with left bar</label>
  17.                     <template>page/2columns-left.phtml</template>
  18.                 </two_columns_left>
  19.                 <two_columns_right>
  20.                     <label>2 columns with right bar</label>
  21.                     <template>page/2columns-right.phtml</template>
  22.                 </two_columns_right>
  23.                 <three_columns>
  24.                     <label>3 columns</label>
  25.                     <template>page/3columns.phtml</template>
  26.                 </three_columns>
  27.             </layouts>
  28.         </cms>

Using the same steps, and modifying them for your application, you can crate new layout templates for use on any CMS page.

Be aware that until Magento changes the way layout templates are invoked, any update to the Magento code base will overwrite your changes, so make sure you have a backup of config.xml before you upgrade your Magento installation. The templates themselves will be fine, but you won’t be able to select them in the admin interface until you update config.xml so they show up.

To avoid this, make the change in (make a backup of config.xml and copy):


Then in: app/etc/modules/Mage_All.xml Added in:

  1. <xml version = "1.0"?>
  2.        <config>
  3.            <modules>
  4.                <Mage_Page>
  5.                    <active> true </ active>
  6.                    <codePool> local </ codePool>
  7.                    <depends>
  8.                        <Mage_Core/>
  9.                    </ depends>
  10.                </ Mage_Page>
  11.            </ modules>
  12.        </ config>

Then finally, in the local module CMS, create folders Page and etc in local Mage, see :


And in this file, make the amendment, it is untouchable by updating the core, because it is in the local folder.

You can update to the core, and no problem with that.