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.

Magento 2.4.7 is here!
E-commerce
David Pratt

Magento 2.4.7 Has Arrived!

Magento 2.4.7 is set to land, with the latest release due to be launched on Tuesday the 9th of April 2024. The latest updates sees over 150 performance and security fixes as well as platform enhancements and upgrades.
Read More »
DTF Digital