Richard Castera

Application Developer/Designer
  • Home
  • About
  • Projects

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() ?>
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Don't forget to Subscribe and Follow!

Be sure to subscribe to the feed and follow me on Twitter for more insights and resources!

25 Responses to “Magento – Adding Static Block content to a Page”

  1. Comment #1 - Permalink
    x4hai
    05/22/2009

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

  2. Comment #2 - Permalink
    blade
    07/02/2009

    what page?
    where in the page?

  3. Comment #3 - Permalink
    Richard
    07/04/2009

    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!

  4. Comment #4 - Permalink
    Fernando Emmanoel Borba
    07/29/2009

    Tiny post, GREAT solution!! Thank you Richard!

  5. Comment #5 - Permalink
    Richard
    07/31/2009

    @Fernando, Thanks!

  6. Comment #6 - Permalink
    Brad
    08/10/2009

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

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

  7. Comment #7 - Permalink
    Richard
    08/11/2009

    @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.

  8. Comment #8 - Permalink
    Meggan
    09/14/2009

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

  9. Comment #9 - Permalink
    Richard
    09/14/2009

    @meggan, Thanks!

  10. Comment #10 - Permalink
    Michael
    09/17/2009

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

  11. Comment #11 - Permalink
    Richard
    09/26/2009

    @michael, I’m happy you found this useful!

  12. Comment #12 - Permalink
    Tom
    09/26/2009

    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

  13. Comment #13 - Permalink
    Richard
    10/06/2009

    @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-content-to-a-page/

  14. Comment #14 - Permalink
    Kelli
    10/28/2009

    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

  15. Comment #15 - Permalink
    Spenser
    10/29/2009

    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.

  16. Comment #16 - Permalink
    Richard
    11/01/2009

    @Spencer, Thanks!

  17. Comment #17 - Permalink
    Richard
    12/06/2009

    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.

  18. Comment #18 - Permalink
    Craigboi
    12/14/2009

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

    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

  19. Comment #19 - Permalink
    Richard
    02/16/2010

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

  20. Comment #20 - Permalink
    Tomas
    04/12/2010

    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 :-(

  21. Comment #21 - Permalink
    Tomas
    04/15/2010

    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);

  22. Comment #22 - Permalink
    Magento Development
    05/07/2010

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

  23. Comment #23 - Permalink
    Tomas
    06/29/2010

    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-extension.html

  24. Comment #24 - Permalink
    Brando Bandit
    07/27/2010

    Thanks for this Richard! Saved my time!

  25. Comment #25 - Permalink
    santhosh
    08/17/2010

    hi richard,

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

    and how to pages in menu?

It's Your turn

Click here to cancel reply.
You

CAPTCHA Image
CAPTCHA Audio
Refresh Image



About The Author

Richard is a Web Developer currently working for SankyNet. He is available for freelance work. Visit Shifting Ideas for inquiries. Thanks!
  • Premium Email Templates

    Social Profiles

  • Twitter
  • Facebook
  • LinkedIn
  • Digg
  • Google
  • GitHub

    Last Tweet

  • J. K. Rowling donates $15 million for MS clinic http://om.ly/tkkw
  • Follow me
  • Archives

    • August 2010
    • July 2010
    • June 2010
    • May 2010
    • April 2010
    • March 2010
    • February 2010
    • October 2009
    • September 2009
    • August 2009
    • July 2009
    • June 2009
    • May 2009
    • September 2008
    • August 2008
    • July 2008
    • June 2008
  • Categories

    • AJAX
    • Apache
    • Books
    • Drupal
    • Ecommerce
    • Flash
    • Google
    • Javascript
    • jQuery
    • Magento
    • Marketing
    • Mootools
    • My Thoughts
    • MySQL
    • News
    • Photoshop
    • PHP
    • Prototype
    • SEO
    • Web Resources
    • Wordpress
  • My Favorites

    • 37 Signals
    • Andrew Warner
    • Chris Coyier
    • Chris Shiflett
    • Collis Ta'eed
    • Development Seed
    • Drupal
    • HubSpot
    • James Padolsey
    • Joel On Software
    • John Resig
    • jQuery
    • Kevin Rose
    • Life Hacker
    • Magento
    • Mashable
    • Matt Cutts
    • Matt Ryan
    • MySQL
    • NetTuts
    • Noupe
    • Photoshop Tutorials
    • PHP
    • Smashing Magazine
    • Tech Crunch
    • WoorkUp
    • Wordpress

2010 © Copyright. Richard Castera - All Rights Reserved.

Top