Sometimes you have situations where you have to create a custom template for your Magento webshop. Take a homepage for example. These pages are always themed with slideshows, categories, advertisements, etc. The last thing you want is misuse the wysiwyg editor, bloating your CMS content with HTML and keep your fingers crossed that your client doesn’t accidentally destroys the whole layout and blames you for it!
A custom template might be just what you need in this case. And creating one is actually quite simple. Let’s take the homepage as an example.
Add a custom template to your module.
The first thing you need is a module. I assume you already know how to define a module in Magento, and otherwise there are plenty of articles out there covering this topic. The only thing you need to do now, is define a new template in the etc/config.xml of your module:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
<config> <modules> <Package_Homepage> <version>0.0.1</version> </Package_Homepage> </modules> <global> <page> <layouts> <homepage translate="label"> <label>Homepage</label> <template>page/homepage.phtml</template> <layout_handle>homepage</layout_handle> </homepage> </layouts> </page> </global> </config> |
That’s it! You now have an extra template to choose from. Now the only thing you need to do is make sure that the file page/homepage.phtml exists in your template folder.
Visitors give this article an average rating of 4.0 out of 5.
How would you rate this article?
★ ★ ★ ★ ★