«Back to blog home

Using Magento as a CMS

Magento

Making a page in Magento packed full of your lovely SEO keyword driven content is easy, really easy. But what happens when you want to get that content somewhere that isn't one of those pages? That's when everything falls apart...

Let's get this straight from the get go- Magento is not a content management system and at this point it's not really trying to be one... well, maybe just a little. It's got pages, templates and static blocks which can be embedded within each other. Confused? I'd suggest taking a look at the Design Terminologies page. With these 3 main tools and some imagination you can do quite a bit in terms of ensuring that content on a site is editable via the cms.

Unfortunately other than a brief front-end overview, Magento's developer documentation is non-existent. Luckily there's a pretty good community of developers willing to share what they've learned. Throughout my adventures with Magento I've kept a running list of different ways you can grab content from somewhere else, here's some of the most commonly used ones.

Embed a Static Block Within a Page

So you've got a static block of content that you want to put inside of a page, cool. Just drop this snippet in the page's content textarea and the static block with and id of "foo-block" will magically appear.

  {{block type="cms/block" block_id="foo-block"}}

Get a Static Block's Content From Within a Template File

This does the same thing as above except instead of being used in a page, it's used in a template file.

 $this->getLayout()->createBlock('cms/block')->setBlockId('foo-block')->toHtml();

Inserting a Template file Inside of a Page's Content

You'll notice the curly braces, that means it's a CMS tag like our first example. Just two things have changed, The type of block is different and in the template attribute you specify the path relative to your templates folder.

 {{block type="core/template" template="path-to-template.phtml"}} 

Templates in Templates

You're in a template file and you want to include another template file in it, chances are you should probably be using Magento's block layout system for this rather than manually including it the template. Regardless of best practices, here's how it's done.

 $this->getLayout()->createBlock('Mage_Adminhtml_Block_Template', 'block-name')->setData('template', 'path-to-your-file.phtml')->toHtml();

Here is a great resource that dives deeper into various CMS syntax tags Magento CMS syntax – part1

Comments

Rob Zienert (not verified) says:

You should write a blog post on extending Magento. Or maybe that would be for me.

My objective, unbiased and completely professional review of the Magento E-Commerce platform: It is one of the most tremendously heinous applications I've ever had to deal with. The greatest over-engineering abomination sent from the very most vile, wretched depths of the earth with it's sole objective to make a developer's life hell--laughing maniacally as you tip-toe through it's broken architecture, hoping not to fall into the dark chasms waiting to swallow your soul wholly for all eternity. Those who enter Magento lose a part of their humanity without hope of ever seeing it again. It lies waiting to victimize all who decide to leverage the power that which lies beneath.

Too much? Yeah, it's a pretty good system until you have to do crazy things with it.

Toni Anicic (not verified) says:

Thanks for linking to us Zack. You're right, Magento is not much of a CMS. This is why we usually integrate it with WordPress for clients that need content management :)

Magento Technologies (not verified) says:

it is possible but why use Magento as CMS when you have so many great CMS platforms out there like wordpress?

It's really a must for developers to know how they will be using magento and clarify that they really need a magento site not a CMS

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

zach Wood

I’m Zach, a Client-Side Engineer here. What does that mean? It means I’m responsible for all the fun stuff your browser (the blue “e” on your desktop) displays. I take those cutesy designs you love and turn them into something useable on the web. When I’m not crushing it at the Purple headquarters, you can find me scooting my bicycle around Downtown Orlando complaining about all of the cobblestone streets. I’ve got a computer-screen suntan, live directly above the railroad tracks, and get overly excited when Hulu alerts me about a new “30 Rock” episode.

my Favorites

Bikes

Bicycle Death Count:
Stolen: 2
Crushed by SUV: 1

Orlando Magic Basketball

Dwight & Vince & Matt & Rashard & Jameer.

my Last·fm

  • xx
  • I And Love And You
  • Contra
  • Family

my Flickr

  • Ze Cake!
  • me, 2010.
  • Too Tight
  • Orlando, tilt-shifted from the 30th floor.