Displaying a custom CMS attribute on the Magento frontend

by Nick Kravchuk

June 5, 2012 Comments (2)

In this article we would like to share with the community one of the ways to display a custom CMS attribute on the Magento frontend. In my previous article I have explained how to add a CMS attribute at the backend. Check it out here (Adding a custom attribute to the CMS page).
There is no way to display an attribute without calling getAttribute or getData methods in the template, but we can also create our own template as an option.
First of all, you should create your custom layout. Then add the following code to your config.xml under the <global> scope:

After this, in the layout dropdown at the CMS editing page you can select your custom layout. See below:
Next, you should create your custom file atwix-page.phtml under app/design/frontend/../../template/page/atwix-page.phtml
You can just copy the content from 1column.phtml, 2columns-left.phtml, etc…
then you can insert the following snippet anywhere you want in your file (atwix-page.phtml)

Function getContentCustom is returning a value for the ‘content_custom’ field from the ‘cms_page’ table
If you don’t want to create a template file, you can move the CMS page template file to the folder that contains your custom theme and the edit it.

UPDATE: I’ve found a different way to do this with layout xml. Magento allows to display your own CMS attribute on the frontend using another method. First, you should create the template file that will display your attribute values, in our case it is atwix/cmsattribute.phtml under app/design/frontend/base/default/template/

function getContentCustom gets value of the ‘content_custom’ field from the ‘cms_page’ table.
After this, we need to add the following XML to your Layout Update XML field under the CMS -> Pages -> Your page -> Design tab.

Subscribe to our blog

Interestedin Atwix?

Smart Brands Choose Us.

From Mark Cuban and Sir Richard Branson backed startups, to Inc 500 US Fastest Growing Companies and Global Brands choose us to deliver and support unparalleled eСommerce experience for their customers.