Question

I'd like to show an icon only in my 'shoes' category listing page (ID: 3).

I've put in place the PHTML which will create the icon in the list.phtml file. But currently it appears in all categories, I want it to appear in just the category 'shoes' which has the ID: 3.

Here's my current code in catalog/product/list.phtml

<div style="position:absolute;top:-10px;right:-15px;">
<img src="mysite.com/myshoesimage.png" width="100" alt="My Shoes Cat Specific Icon" />
</div>

Can anyone please suggest an edit to make this show only in the specific category?

Was it helpful?

Solution

Use this code:

<?php if(Mage::registry('current_category')->getId()==3){ ?>
<div style="position:absolute;top:-10px;right:-15px;">
<img src="mysite.com/myshoesimage.png" width="100" alt="My Shoes Cat Specific Icon" />
</div>

<?php } ?>

OTHER TIPS

You can try:

$catId = Mage::registry('current_category')->getId();

if($catId==3):?>
    <div style="position:absolute;top:-10px;right:-15px;">
        <img src="mysite.com/myshoesimage.png" width="100" alt="My Shoes Cat Specific Icon" />
    </div>
<?php endif;?>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top