开发者

How to display tags product in view.phtml of Magento

开发者 https://www.devze.com 2022-12-16 18:33 出处:网络
I created new theme and use them for creating product. In view page, I don\'t see product tags. I review view.pthml in default and know that the tags in \"e开发者_StackOverflowcho $this->getChildHt

I created new theme and use them for creating product. In view page, I don't see product tags. I review view.pthml in default and know that the tags in "e开发者_StackOverflowcho $this->getChildHtml('product_additional_data') ", my view.phtml has it too but why it don't display tags

plz, any advice


This is what I did after about 4 hours of research.

<?php
// instantiate the tags class for products
$_tags = new Mage_Tag_Block_Product_List();
?>

<ul class="product-tags">
<?php foreach($_tags->getTags() as $tag):?>
    <li><a href="<?=$tag->getTaggedProductsUrl()?>"><?=$tag->getName()?></a></li>
<?php endforeach;?>
</ul>

I don't like having to instantiate the class, so if I find a more elegant way I'll update my post. But at least it a php only solution.


Does your catalog.xml's catalog/product_view block define something like this?

<block type="catalog/product_view_additional" name="product.info.additional" as="product_additional_data" />

In my Modern Theme store the tags are displayed using the template/tag/list.phtml hint path.

Hope this helps.


@Boss Ninja: it works perfectly if your tag.xml file is enabled in layout directory (app/design/frontend/default/default/layout).


Define at XML layout in catalog_product_view section:

<block type="catalog/product_view_additional" name="product.info.additional" as="product_additional_data" />

And then in your phtml where you want it to display:

<?php echo $this->getChildHtml('product_additional_data') ?>

Ensure that Mage_Tag module is enabled at "System --> Configuration --> Advanced".

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号