Magento Tips, Tricks, and Hacks #6: How to add a CMS Static Block to a page

Magento Tips, Tricks, and Hacks — By ScreencastWorld on March 19, 2010 at 15:48

Static blocks are a great way to divide up different types of data blocks to make updating content easier.  They are incredibly flexible, allowing you to create something as simple as a text category description, product highlights, or promotions.  Here’s an example of a static block from the Magento Demo Store:

Static Block Example

Static Block Example

There are just two simple steps to adding a static block to a cms page.  First, create your static block. You will use the identifier to call it on the cms page.  To create a static block go to CMS -> Static Blocks, then select Add New Block.

Create New Static Block

Create New Static Block

Once your static block is created, edit the CMS page you would like this block to appear on, and simply put this code in right where you want it to show up:

{{block type="cms/block" block_id="cellphones-landing"}}

If you wanted to add the static block within your template code use the following:

<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('cellphones-landing')->toHtml() ?> 

Don’t forget to subscribe to the RSS Feed and follow us on Twitter.

Related posts:

  1. Magento Tips, Tricks, and Hacks #5: How to add ‘Featured Products’ to your home page
  2. Magento Tips, Tricks, and Hacks #1 – Backups
  3. Magento Tips, Tricks, and Hacks #4: How to link pages using store URL short code
  4. How To Enable Template Path Hints and Add Block Name Hints
  5. Magento Tips, Tricks, and Hacks #2: Check for dead links
Tags: , , , ,

Comments are closed.