Static Blocks in Magento 03 Mar

Magento Static Blocks

Static blocks are a Magento feature that makes adding content to your Magento site easy and convenient. Static blocks allow for your Magento site to be updated via the admin panel making it faster than having to “hard-code” every time you need to make a change to your website. Static blocks can be used anywhere on your Magento site to display text, images, & navigation.  Some Magento designs have static blocks already in place for your convenience; however, you might have to install them yourself. Below is a simple tutorial on how to install a static block in the footer of your Magento site

Step One: Create Static Block in Your Magento Admin

Magento Admin Panel—>Static Blocks—>Add New Block

1) Name your Static Block, in this case Custom footer Links

2) Label the Identifier (This is the link you will use to call the block later) in this case, custom-footer-links

3) Choose what store view you would like it to render in

4) Set Status to Enabled

2)Now for the fun part! Add your navigation links to the block.   Make sure to use <style> to make them match your sites color and theme.

Step Two: Inserting Code to Call the Static Block

This part is going to require you to FTP into your Magento site and modify footer.phtml
app—>design—>frontend—->default—>(your template)—>template—>page—>footer.phtml

Find where in the footer you want your navigation links to display and insert:
<?php echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘custom-footer-links’)->toHtml(); ?>

Now most of the time the Static block should display just fine but in some cases you are going to have do some extra steps to have the block display.

1) Instead of inserting:
<?php echo $this->getLayout()->createBlock(‘cms/block’)->setBlockId(‘custom-footer-links’)->toHtml(); ?>

Use:

<reference name=”left”>
<block type=”cms/block” name=”left.permanent.callout”>
<action method=”setBlockId”><block_id>custom-footer-links</block_id>
</action>
</block>
</reference>

2)Modify catalog.xml
app—>design—>frontend—>default—>f002—>layout—>catalog.xml

Add under <!– Mage_Catalog –>

<block type=”cms/block” name=”left.permanent.callout”>
<action method=”setBlockId”><block_id>custom-footer-links</block_id>
</action>
</block>

And voila! Your Static Blocks should be displaying and easily accessible through Your Magento Admin panel. Remember Static Blocks can be inserted just about anywhere in your Magento site and are a great feature to use when content needs to be updated frequently. If you have any comments or suggestions on Magento Static Blocks feel free to leave them below.

<block type=”cms/block” name=”left.permanent.callout”>
<action method=”setBlockId”><block_id>promo-images</block_id>
</action>
</block>
4 Responses to “Static Blocks in Magento”
  1. Yogs Reply

    Hi thanks for such a nice post my problem is i want to display Static block in right side of my page on Selected categories like i have three categories Womens,Mens,Children now i want to set diffrent block for each category in right side pls. help how to do it i set block for each category in middle but how to set this in right side in my site pls. help regarding same

    Thanks

    • Thomas Reply

      That would require code modification to work. A database call looking in the Static Blocks for a matching name would do the trick
      You could also look for an extension that would accomplish the same thing.

  2. Tiny Toys Reply

    My footer links are working fine. But I am trying to add a static block for some pages which would be footer text that appears under the footer links.

    So I created a static block and on the page where i wanted it to appear, I added this as the custom xml layout update. This way I got the block to appear only on the pages that I wanted it to appear on.

    toy-story-page-footer-block

    All this was done via the admin, no change in codes.

    But all of a sudden, none of the footer blocks seem to appear, I haven’t changed any settings. I use filezilla for ftp and I may have accidentally moved some folders, I am trying to figure out if I did or not.

    Have been trying to fix this for the past month and have read every form possible.

    Any help will be really appreciated.
    Tiny Toys´s last blog ..Repetitive motions and sounds soothe babiesMy ComLuv Profile

  3. Kent Reply

    Hi there – wondering if you can help with how I would add a cms block to the right area of the account registration page of Magento?

    Thank you

    Kent

Leave a Reply

do-follow


CommentLuv Enabled

Contact Us for a Free Consultation

Call us: 800-447-6024
-or complete the below form-

Name (required)

Email (required)

Phone (required)

Your Budget

*Full builds (design and development) start at $10K

Message

Please Enter Verification Code Below:
captcha

About

At InteractOne, we have provided web development and Internet services to medium and small business since 1998. As the world goes online, we’ve helped many companies develop and establish very successful internet strategies, websites, and e-commerce sites.

We focus on providing direct, one-to-one service to businesses and organizations in a cadre of industries. We are committed to ensuring that our clients receive careful attention and the highest quality when we plan, develop, design, and construct a website. Helping you succeed on the Internet is our primary objective.

Corporate Office:

800-447-6024

local: 513-469-7042


4700 Ashwood Drive
Suite 450
Cincinnati, OH 45241-2477

Follow InteractOne on facebook Follow InteractOne on Twitter