For all enquiries please call or email us. 01484 506220info@designthatfits.co.uk

Magento - Custom Page/CMS Templates

Every now and again you need to add your own CMS templates to Magento, here's how.
Mar 24, 2015
Every now and again you need to add your own CMS templates to Magento, here's how.

Uses of this functionality may vary, but we find it inevitable that you need to add your own CMS template to magento. Most often we need to do this to add a custom homepage template which typically has a very different layout to the rest of your shop. Short of putting everything into your CMS page itself which can be messy and make it easy to break a page we would recommend any non-cms content/functionality be put in the template (You could always call in some less frequently edited pieces of content via a few static blocks).

So, we'll start with the standard module XML file:

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

And set up our file/folder structure within app/code/community:

  • Designthatfits/Newtemplates/etc/config.xml
And in the template folder: /app/design/frontend/default/yourtheme/template/page/home.phtml

Adding a new page template is probably one of the most basic extensions and only requires the following within the config.xml file:

<?xml version="1.0"?>
<config>
<modules>
<Designthatfits_Newtemplates>
<version>0.1.0</version>
</Designthatfits_Newtemplates>
</modules>
<global>
<page>
<layouts>
<home translate="label">
<label>Home</label>
<template>page/home.phtml</template>
<layout_handle>page_home</layout_handle>
</home>
</layouts>
</page>
</global>
</config>

By placing your new templates withing the <layouts> section you define a) the location of the template file, b) it's name, c) it's handle.

The final task is to fill your phtml file with the relevant content. Refresh your cache and indexes and you should then be able to access the new template when creating your CMS page.

Return to articles
Fishpig's Wordpress extension was a key part of any magento 1.9.x project. This hasn't changed with Magento 2, but...
Marketing automation is a great asset for any business and once set up requires very little maintaining.
If you use plesk to run Magento 2 you might find difficulty when you come to run bin/magento commands
We'd suggest adding address lookup to the checkout.

Businesses can trust us to deliver effective online marketing solutions. Find out why.

Speak to an expert