Try the Demo

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

 Signature 

http://www.igentics.com

Igentics are Internet Engineers, we like to look at things from a different angle. The end result being a fully integrated system encompassing the whole supply chain from supplier to end user, incorporating all legacy systems and data. This increases profits and reduces cost.

 
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.

 Signature 

- I would love to change the world, but they won’t give me the source code -

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

Excellent, I look forward to it!

 Signature 

http://www.igentics.com

Igentics are Internet Engineers, we like to look at things from a different angle. The end result being a fully integrated system encompassing the whole supply chain from supplier to end user, incorporating all legacy systems and data. This increases profits and reduces cost.

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