Web Components
- February 17, 2009
Magento CMS : 2 methods for static blocks
Magento’s backoffice comes with a fairly simple CMS that can do a lot : single pages can be modified (content and layout) via the CMS / Manage Pages menu, and page parts can be shared and modified via the CMS / Static Block menu. Web developers who get a first sight inside templates might find it difficult to integrate a newly created block : we describe here two methods to integrate a block in your magento website.
How to create a CMS block : Go to Magento admin uder CMS -> Static Blocks and Add New Block. Insert Block Title, Identifier (for example: mycompany-newsblock), set Status to Enabled, insert block Content and Save Block.
How to add the CMS block to pages (exemple on the right column). You can choose one of these 2 methods
- LAYOUT block modification: in layout/page.xml , find the default / right column block
<block type=”core/text_list” name=”right” as=”right” />
and transform it by incorporating the newly created CMS block :
<block type=”core/text_list” name=”right” as=”right”>
<block type=”cms/block” name=”ruedesiam.marge” as=”ruedesiam.marge” after=”-”>
<action method=”setBlockId”><block_id>mycompany-newsblock</block_id></action>
</block>
</block> - Template block addition : add the following code to
app/design/frontend/YOURTEMPLATE/default/template/callouts/right_col.phtml
<?= $this->getLayout()->createBlock(’cms/block’)->setBlockId(’mycompany-newsblock’)->toHtml() ?>
The solutionbelow explains how to add a template block : everything here is done via HTML files. (example for theleft column)
1. in layout/page.xml or in your page custom design, add the following code
<reference name=”left”>
<block type=”core/template” name=”productbrand” alias=”productbrand” as=”productbrand” template=”catalog/product/brand.phtml” />
</reference>
2. in template/callouts/ left_col.phtml, add the following :
<? $this->getChildHtml(’productbrand’) ?>



3 Responses to “Magento CMS : 2 methods for static blocks”
thank you,it’s very helpful.
By justin on Mar 26, 2009
I use Free CMS module, it’s very useful. You can see the demo here: http://demo.hello-magento.com/freecms/furniture.html
By x4hai on May 22, 2009
Hi,
…not sure if this is in the right area or you can help but I am having trouble adding a static block in a newsletter template. I have tried adding {{block type=”cms/block” block_id=”block-id”}} in the template but on preview it interprets this as a string and the static block does not appear. No response from the Forum. Any ideas? Thanks.
Tim.
(www.mytex.co.uk – mobile computing office bundles)
By Tim on Jun 2, 2009