0

I have a small problem and try to solve them. I search for a while now for a solution but can't find something that match my problem.

My case is that i have different root categories with different topics. So the final result should be that i can insert different static blocks in my sidebar for different topics that depends on that topic.

For example if you are in the section for electronics then you get on the right site a banner with the number from that department which can help you directly.

That is only one example there you should more boxes that are different. So does anybody know if there is an extension to solve that problem? Or is there a native solution to solve that problem?

The best way would be that i can select a root category on static blocks or something else.

2 Answers 2

1

Add a new CMS block and give it an ID like support_electronics. Fill it as you wish.

Open your corrsponding category and in the tab Custom Design you update the design by using Magento's layout XML in the textbox Custom Layout Update XML.

You then can address your right sidebar and add a new CMS block by for example:

<catalog_category_view>
    <reference name="right"> <!-- or left, whatever -->
        <block type="cms/block" name="support_block" before="-">
            <action method="setBlockId"><block_id>support_electronics</block_id></action>
        </block>
    </reference>
</catalog_category_view>

(same for layered view of course)

Note that before="-" will move to the first position inside your sidebar. You can change that of course.

Feel free to use the different storeViews with you newly created CMS block to make it multi-lang.

UPDATE

You can even use the option Apply To Products inside the Custom Design tab of your category. So your settings can be inherited to the products inside your category. I never used this, but give it a try with:

<catalog_product_view>
    <reference name="right"> <!-- or left, whatever -->
        <block type="cms/block" name="support_block" before="-">
            <action method="setBlockId"><block_id>support_electronics</block_id></action>
        </block>
    </reference>
</catalog_product_view>
1
  • 1
    Thanks for your answer :) that sounds like a good solution i think i can use that :) thx for your effort. Commented Sep 19, 2015 at 10:26
1

I don't know what you have tried so far, but here's how I would do it:

Could work

First, insert a block on each category page in my local.xml:

<catalog_category_view>
    <reference name="right"> <!-- or left, whatever -->
        <block type="core/template" name="super_special_cat_block" template="catalog/something.phtml />
    </reference>
</catalog_category_view>
<!-- repeat for layered categories -->
<catalog_category_layered>
    <reference name="right"> <!-- or left, whatever -->
        <block type="core/template" name="super_special_cat_block" template="catalog/something.phtml />
    </reference>
</catalog_category_layered>

Afterwards, here comes the catalog/something.phtml file:

<?php

// get current category data
$_category = Mage::registry('current_category');

if(!$_category) {
    return;
}

// load the special block for this category
// for example the cms block with identifier
// category_block_1 for category with ID 1
echo $this->getLayout()->createBlock('cms/block')->setBlockId('category_block_' . $_category->getId())->toHtml();

Your content team could then simply create those blocks with the unique identifiers.

This is better

However, now that I think of it... you can configure categories in magento to display "Products and static block". After that, you can actually choose a cms block to be displayed with this category. The default is that this block will be displayed above the product-list, but after a short look into catalog/category/view.phtml, you should be able to display it in the something.phtml file instead.

1
  • 1
    Thx for your answer. But the other solution from "Ni Ge" sounds a bit easier for me :) Commented Sep 19, 2015 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.