Jump to content

How to output the first tag only of each product


joshua_lee

Recommended Posts

Hi guys,

 

I've used Vekia's awesome code for tags on my shop for a few years now.  Now I would like to just pull (for output) the first tag of each product for SEO.

 

Is there anyone who would know how to do this?

 

This outputs all tags:

 

{foreach from=Tag::getProductTags(Tools::getValue('id_product')) key=k item=v}

  {foreach from=$v item=value}

    {$value|escape:html:'UTF-8'}

  {/foreach}

{/foreach}

 

I would just like to output the first one, if possible. Thanks!

 

 

 

Link to comment
Share on other sites

Try this

{assign var='tags' value=Tag::getProductTags(Tools::getValue('id_product'))}
{foreach from=Tag::getProductTags(Tools::getValue('id_product')) key=k item=v}
 {foreach from=$v item=value name=value}
 {if $smarty.foreach.value.first}
 {$value|escape:html:'UTF-8'}        
 {/if}  {/foreach}
{/foreach}
Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...