Magento - Adding Static Block content to a Page

Add Magento static blocks to your page easily! Simply copy this line of code below where you want the static block to appear and change the 'identifier' to the identifier of the static block you created. That's it!

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

30 comments for Magento - Adding Static Block content to a Page

x4hai's picture

I use Free CMS module that is...

I use Free CMS module that is very useful. You can see the demo here: http://demo.hello-magento.com/freecms/furniture.html

blade's picture

what page? where in the page?...

what page?
where in the page?

Richard's picture

Hey Blade, basically to any...

Hey Blade, basically to any page you want. You just need to have an identifier that exists for a specified block. So if you where to create a static block by going to CMS -> Static Blocks and click on Add a new block, give it a title, identifier, set the status to enabled and add some content. Hit save. Now to add that static block to a page, locate the page you want to add this blocks content to and add the line of code in this post. Don't forget to change the identifier to the identifier you specified when creating the static block. That's it!

Fernando Emmanoel Borba's picture

Tiny post, GREAT solution!! ...

Tiny post, GREAT solution!! Thank you Richard!

Richard's picture

Thanks Fernando!...

Thanks Fernando!

Brad's picture

Is there a reason I shouldn't...

Is there a reason I shouldn't just use this method?


{{block type="cms/block" block_id="my_block" template="cms/content.phtml"}}

Richard's picture

Brad, Sure there is... The...

Brad, Sure there is... The method that you specified is used to add the content inside a CMS page. The method in the post is used to add content to a .phtml page. Hope this helps.

Meggan's picture

This was really helpful!...

This was really helpful! Thanks for posting it. (You probably already know how hard it is to find concise Magento solutions like this!)

Richard's picture

Thanks!...

Thanks!

Michael's picture

This is EXACTLY what I was...

This is EXACTLY what I was looking for! Great solution. Thank You Richard!

Richard's picture

Michael, I'm happy you found...

Michael, I'm happy you found this useful!

Tom's picture

Hi Richard thanks very much...

Hi Richard thanks very much for this. It is a clear and straight to the point instruction (unlike many other magento guides out there)

Could you please tell me what I would need to do to add something just above the footer of all pages (I would like to have a paypal verified image)

I am new to magento and still learning coding, it is quite confusing.

Thanks again

Richard's picture

Tom, you can look at this...

Tom, you can look at this post on creating a static block in Magento, http://www.richardcastera.com/2009/05/18/magento-adding-static-block-con...

Kelli's picture

Hi Richard, does this work if...

Hi Richard,
does this work if it's not a static cms page would it work on a product category page and how do you access it?

Thanks, Kelli

Richard's picture

Hey Kelli, Sure you can add a...

Hey Kelli,

Sure you can add a static block to a Product Category Page! Your best bet is to add it VIA the layout file.

Spenser's picture

Dear sir, I've been working...

Dear sir,

I've been working on M for about a week and am still trying to piece together how everything works. Thank you so much for your assistance and sharing.

Richard's picture

Thanks!...

Thanks!

Craigboi's picture

Hi Richard, great post!! got...

Hi Richard, great post!! got a bit of a headache tho Sad

how can you make CMS block appear above a category page layout?

For example: if you have 2columns-left set as your category page layout how can i make a CMS block appear above this layout? and also be able to add a different block to each category page via the admin panel?

here is my problem http://gogglefirm.com/snow.html

as you can see i have the static block in the page but i want it to clear the left col and main col.

any ideas

Cheers
Craig

Richard's picture

Craig, you can follow this...

Craig, you can follow this article to achieve what your looking for: http://www.richardcastera.com/2009/05/20/magento-re-ordering-block-items/

Tomas's picture

Hi. Can I have one question?...

Hi. Can I have one question? There are possibility to use static block in product description? When I put


{{block type="cms/block" block_id="dima_test" template="cms/content.phtml"}}

to them I see only this text, no block content Sad

Tomas's picture

I found solution it is...

I found solution it is necessary only add this two lines in the proper place into app/code/core/Mage/Catalog/Helper/Output.php to method productAttribute()


$processor = Mage::getModel('core/email_template_filter');
$attributeHtml = $processor->filter($attributeHtml);

Magento Development's picture

Good solution. it is very...

Good solution.
it is very helpful for us
thanks for the help richard.

Tomas's picture

Hi, I have searched for...

Hi, I have searched for solutions everywhere, but it was too hard or time consuming. And i found this magento extension to show categories where you want as block.

Here is a link: http://www.storefrontconsulting.com/software/featured-categories-magento...

Brando Bandit's picture

Thanks for this Richard!...

Thanks for this Richard! Saved my time!

santhosh's picture

hi richard, can u explain me...

hi richard,

can u explain me how to move menu from top to left or right

and how to pages in menu?

Steve's picture

Thanks a lot, mate. Saved me...

Thanks a lot, mate.
Saved me a lot of trouble Smile

Gary's picture

Thanks Richard, I can't count...

Thanks Richard, I can't count the number of attempts I have made using various code from more than I can count sites/tutorials and yours is the first that has worked . I finally have additional content added to my site

nicholas's picture

Hi richard, thanks for the...

Hi richard, thanks for the help and it is a good solutions.

Melanie @ tinytoys's picture

i have static footer blocks...

i have static footer blocks with relevant SEO text for certain pages. It was working fine and all of a sudden all the static footer blocks disappeared. I cant seem to get it back. This is the code U used:


<reference name="footer">
<block type="cms/block" name="home_page_footer_seo_block" after="home_page_footer_block">
<action method="setBlockId">
<block_id>home_page_footer_seo_block</block_id>
</action>
</block>
</reference>

I added this code in the layout update XML section in the design tab of the homepage.

Any help is appreciated

Amrish's picture

Hello i am new in magento...

Hello

i am new in magento and learn all things, but i have question
1) i create one "Education price" name page
2) i Create a Static Block Name "Prices" in that static block i write some content and also "click here" link
3) i want to show the "Education price" in click of "click here" link

so how can i do that plz help me

Thank YOu
Amrish

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.