0

I have 5 root categories and I want different left sidebar image for each category. I'm using Porto theme in which I can fix a static block in my left sidebar but then it cannot change the image according to category. Example: poster of tshirts in Fashion category and poster of headphone in Electronics category. I'm using magento 1.9

0

Well static blocks are... static. You have two options here. 1. Create a widget

  1. Add a phtml file in your template that does what you want.

For (2), Insert sth like this in your static block

{{block type="core/template" template="catalog/category/image.phtml"}}

Then create app/design/frontend/[package]/[theme]/template/catalog/category/image.phtml with the following content

<?php if($categoryId=Mage::registry('current_category')):?>
    <?php /*Add your image logic here. For example*/?>
    <?php switch ($categoryId) {
    case 11:
        $categoryImage = 'cat11.jpg';
        break;
    case 12:
        $categoryImage = 'cat12.jpg';
        break;
    case 13:
        $categoryImage = 'cat13.jpg';
        break;
     default:
        $categoryImage = null;
     }?>
     <?php if($categoryImage):?>
        <img src="path/to/image/<?php echo  $categoryImage;?>"/>
     <?php endif;?>
<?php endif;?>

The switch is just an example. You can for example get the Category Image from the categories collection

0

This made it work, first I created a static block "activity_tracker_poster" then in activity tracker's category >> Custom design >> Custom Layout Update, I wrote this.

<reference name="left"> 
<block type="cms/block" name="left_block" before=' '>
<action method="setBlockId"><block_id>activity_tracker_poster</block_id></action>
</block>
</reference> 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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