Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Include different CMS blocks per cateogry
 
Dan Orsborne
Member
 
Total Posts:  72
Joined:  2007-09-20
 

Just a quick little trick to get Magento to include different CMS blocks per category whilst using the same template. This is useful for varying the additional content that appear within each category. Here’s how to do it:

In your template file add

<!-- CMS Block Category View Right Column -->
<?
$_var1 
'category_right_' strtolower(Mage::registry('current_category')->getName());
 
?>
<?
=$this->getChildHtml($_var1)?>

This will try and call a CMS block with the name ‘category_right_cateogryname’.  Obviously this will vary according to the categories you have in your site but for each different category you need to add the following into \app\design\frontend\OC\default\layout\core\default.xml where ever you want them to appear.

<block type="cms/block" name="category_right_ladieswear">
<
action method="setBlockId"><block_id>category_right_ladieswear</block_id></action>
</
block>
        
<
block type="cms/block" name="category_right_menswear">
<
action method="setBlockId"><block_id>category_right_menswear</block_id></action>
 </
block>

It’s not the most elegent solution but perhaps it will get someone thinking about how to improve the CMS usagae within Magento.

Have fun

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1770
Joined:  2007-08-07
Los Angeles
 

Nice smile

In future releases it could be something like this:

<CATEGORY_123>
  <
reference name="content">
    <
block type="cms/block" name="category_right_ladieswear" before="-">
      <
action method="setBlockId"><block_id>category_right_ladieswear</block_id></action>
    </
block>
  </
reference>
</
CATEGORY_123>

Same for <PRODUCT_123>, and <module_controller_action> constructs.

Also, custom layout updates will be stored in database, with conditions per store/package/theme shown.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Dan Orsborne
Member
 
Total Posts:  72
Joined:  2007-09-20
 

Excellent, I look forward to it!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top