Magento – add custom layout template
Tuesday, August 18th, 2009Current magento version – 1.3.2.4
This is what you need to do to add a new layout template, eg 4 column page layout.
- Copy app/code/core/Mage/Page/etc/config.xml
to app/code/local/Mage/Page/etc/config.xml.
Creating this new file will allow magento core updates to occure without over-writing your changes (you’ll probably have to look out for changes to the core config.xml to megre them into your custom file). - Register your custom module by adding a new file to app/etc/modules, called something like Mage_Local.xml
- In this file add the following code:
<?xml version="1.0"?> <config> <modules> <Mage_Page> //relates to file structure <active>true</active> //set to active <codePool>local</codePool> //tell which folder to look in <depends> //requires the mage core <Mage_Core/> </depends> </Mage_Page> </modules> </config>
- Now create your new template file, easy way is to copy an existing one such as 3columns.phtml (in app/design/frontend/your_package/your_theme/template/page), and give it a name, such as 4columns.phtml
- Register this new template in the config.xml file your created in step 1 by adding your module to the layouts list. For my 4 column example I have added:
<four_columns module="page" translate="label"> <label>4 columns</label> <template>page/4columns.phtml</template> <layout_handle>page_four_columns</layout_handle> </four_columns>
You should now be able to access this new template in the cms->manage pages option in the magento admin backend.
