How to display tags product in view.phtml of Magento

后端 未结 4 1348
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-26 00:50

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->g

相关标签:
4条回答
  • 2021-01-26 01:29

    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 讨论(0)
  • 2021-01-26 01:39

    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.

    0 讨论(0)
  • 2021-01-26 01:40

    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.

    0 讨论(0)
  • 2021-01-26 01:44

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

    0 讨论(0)
提交回复
热议问题