문제

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?

도움이 되었습니까?

해결책

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 } ?>

다른 팁

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;?>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top