wan
wan

Reputation: 1

How to display tags product in view.phtml of Magento

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 "echo $this->getChildHtml('product_additional_data') ", my view.phtml has it too but why it don't display tags

plz, any advice

Upvotes: 0

Views: 8264

Answers (4)

joseantgv
joseantgv

Reputation: 2023

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".

Upvotes: 0

mukund002
mukund002

Reputation: 123

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

Upvotes: 0

Boss Ninja
Boss Ninja

Reputation: 171

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.

Upvotes: 3

Ng.
Ng.

Reputation: 1

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.

Upvotes: 0

Related Questions