Aug
25
2010

How to create your own layouts for pages in Magento

To create a page template in Magento we must follow the following steps:

1. Copy the file app / code / core / Mage / Page / etc / config.xml app / code / local / Mage / Page / etc / config.xml.
Creating this file make sure not to lose the changes if you upgrade Magento.
2. Create a file called Mage_Local.xml in app / etc / modules. Therein add the following:

  ?> <? Xml version = "1.0"?>
       <config>
       <modules>
       <Mage_Page>
       <Active> true </ active>
       <codePool> local </ codePool>
       <depends>
       <Mage_Core />
       </ Depends>
       </ Mage_Page>
       </ Modules>
       </ Config> 

3.-We create our new template from any existing app / design / frontend / XXX / XXX / template / page. For example, we can take 3columns.phtml file, make a copy in the same folder and rename it to 4columns.phtml.
4.-Go back to the config.xml file created in step 1, and then add our new template:

  translate = "label" > module = "page" <four_columns "label" translate =>
 <label> 4 columns </ label>
 <template> page/4columns.phtml </ template>
 <layout_handle> page_four_columns </ layout_handle>
 </ Four_columns> 

5.-Once all the above steps, we should see the new template when creating a page in CMS> Pages. Otherwise we must erase the contents of the var / cache our Magento directory, either by hand or through the terminal:
rm-rf * (still within the directory var / cache)


Magento

Leave a comment