joshua_lee Posted May 3, 2015 Share Posted May 3, 2015 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 More sharing options...
ventura Posted May 3, 2015 Share Posted May 3, 2015 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 More sharing options...
joshua_lee Posted May 18, 2015 Author Share Posted May 18, 2015 (edited) Works perfect! Edit - I just noticed the tags are stored in alphabetical order, anyway to store the values in the order they are added or some other way? Edited May 18, 2015 by joshua_lee (see edit history) Link to comment Share on other sites More sharing options...
joshua_lee Posted May 18, 2015 Author Share Posted May 18, 2015 Ok, figured out a solution to my problem, just need to order by tag ID (ORDER BY pt.id_tag) in Tag.php, then make sure your 1st tags are higher up in the ID order. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now