How to add different static block to every category

How to add different static block to every category

September 7, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to add different static block to every category

Adding Different Static Blocks to Every Category in Magento

As an experienced developer at LaravelCompany, I often get asked about customizing the layout of Magento stores on a per-category basis. One common question is how to add different static blocks to specific locations for each category. Let’s dive into this topic and explore how you can achieve this.

Understanding Magento Static Blocks

Before we begin, let me briefly explain what static blocks are in Magento. Static blocks allow you to create reusable content that can be inserted anywhere on your store using block references. They are defined under Content -> Static Blocks in the backend admin panel.

Creating Category-Specific Static Blocks

To add different static blocks for each category, we’ll follow these steps:

  1. Create new static blocks: Go to Content -> Static Blocks and create a new block for each category you want to target. Let’s say you have three categories: “Electronics”, “Clothing”, and “Home”. Create corresponding static blocks like “Category_Electronics_Block” and so on.

  2. Add content: Fill in the content you want to display in each block, keeping it relevant to its respective category. You can use HTML, CSS, JavaScript, or even Magento CMS functions here.

Assigning Static Blocks to Categories

Now, let’s assign these static blocks specifically to their target categories:

  1. Identify the block reference: Look at your category page layout XML files located under app/design/frontend/{your_package}/{your_theme}/layout. You’ll see something like this in the category.xml file:

    <reference name="content">
        <block type="cms/block" name="category_block">
            <action method="setBlockId"><block_id><![CDATA[category_homepage]]></block_id></action>
        </block>
    </reference>
    
  2. Update the block reference: Change the block_id value to match your category-specific block, e.g., <block_id><![CDATA[Category_Electronics_Block]]></block_id>.

Adding Blocks to Specific Locations

Now, let’s add these blocks to specific locations on each category page. In our case, we’ll place them in the footer and banner areas.

  1. Footer area: Open app/design/frontend/{your_package}/{your_theme}/layout/catalog.xml file and find the <reference name="footer"> block. Add a new CMS block reference under this section:

    <reference name="footer">
        <block type="cms/block" name="category_footer_block">
            <action method="setBlockId"><block_id><![CDATA[Category_Electronics_Block]]></block_id></action>
        </block>
     </reference>
    
  2. Banner area: To add a block above the category products, you would typically modify the app/design/frontend/{your_package}/{your_theme}/template/catalog/category/view.phtml file and insert your CMS block reference there.

Remember to clear your cache (bin/magento cache:clean) after making these changes for them to take effect.

Conclusion

In this post, we’ve explored how to add different static blocks to specific locations on a per-category basis in Magento. By creating category-specific static blocks and assigning them appropriately through layout XML files, you can achieve a highly customized look and feel for each of your categories.

This technique demonstrates the power of Magento’s flexibility in allowing developers to create unique shopping experiences tailored to individual product categories. If you want to learn more about advanced Magento customization techniques, I recommend checking out our comprehensive guides at LaravelCompany.

Remember, always validate your code and test thoroughly before deployment, especially when dealing with layout modifications that can significantly impact the user experience.

Happy coding!

Catalog Themes Admin JavaScript

Our network