我想在产品的类别页面上显示子类别图像。1.我用自定义代码创建了category_listing.phtml以显示子类别2.创建了一个静态块
{{block type="core/template" template="catalog/navigation/category_listing.phtml"}}
在类别显示设置中,我选择了“静态块和产品”。说我有三个类别,类别1,类别2,类别3
如果我仅为一个类别选择静态块,则为完美;但如果我在多个类别中调用静态块,则它将显示错误的子类别,除非我每次都删除高速缓存。有没有我遗漏的步骤,请plz考虑到我是magento的新手
谢谢
打开文件:app / design / frontend / yourtheme / default / template / catalog / category / view.phtml并添加以下代码:
<div class="category-grid-new">
<?php $_columnCount = 4;?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="sub-category">
<?php endif; ?>
<?php foreach ($this->getCurrentCategory()->getChildrenCategories() as $_subcat): ?>
<li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0):?> last<?php endif; ?>">
<a href="<?php echo $_subcat->getUrl() ?>">
<div class="category-img"><img src="<?php echo $_category->getImageUrl() ?>" alt="" width="100px" height="100px"/></div>
<div class="category-name"><?php echo Mage::helper('catalog/output')->categoryAttribute($_subcat, $_subcat->getName()) ?></div>
</a>
</li>
<?php endforeach; ?>
<?php if ($i%$_columnCount==0): ?>
</ul>
<?php endif; ?>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句