I can get tags in a view.phtml file like this:
<?php
$_tags = new Mage_Tag_Block_Product_List();
?>
Product Tags:
<ul class="product-tags">
<?php foreach($_tags->getTags() as $tag):?>
<li><a href="<?=$tag->getTaggedProductsUrl()?>"><?=$tag->getName()?></a></li>
<?php endforeach;?>
</ul>
It works fine in a single product page. But the code above doesn't work in categories; it returns error:
Fatal error: Call to a member function getItems() on a non-object in /app/code/core/Mage/Tag/Block/Product/List.php on line 45
As I understand the tags class cannot be instantiated.
But how can I display tags list in a category instead of products? When I click on a tag I should get all products with this tag. Also one tag must not be repeated twice.
Any ideas how to solve this issue?
edited: I'll try to give more details...
There's a layered navigation on my home page called "Gifts". This is a simple filter with attributes.
When I choose some attritube(for example "gender - male") and press "Search" I redirect to a category "Gifts" and get result with products which have an attribute gender "male". But on the first step when I get result I need to display NOT products, I need to display their tags.
For example, a product with attribute "male" can contain some tags "creative, relaxation, father, husband" etc... Another product with attribute "male" can contain the same tags as above, but these tags won't be displayed again. So we see only unique tags from all products.
On the second step when we click on tag "creative" we'll get all products with this tag.
Hope this explanation was helpful.