Tomas LT Posted January 21, 2015 Share Posted January 21, 2015 Hello. Need show product tags on product page. I find this code: <ul class="producttags"> {foreach from=Tag::getProductTags(Tools::getValue('id_product')) key=k item=v} {foreach from=$v item=value} <li><a href="{$link->getPageLink('search', true, NULL, "tag={$value|urlencode}")}">{$value|escape:html:'UTF-8'}</a></li> {/foreach} {/foreach} </ul> But tags are showing two times: tag1, tag2, tag3, tag1, tag2, tag3 How to display each tag one time? Prestashop 1.6.0.11 Link to comment Share on other sites More sharing options...
vekia Posted January 21, 2015 Share Posted January 21, 2015 where you added this code? perhaps in some foreach loop and this is why you see it 2 times Link to comment Share on other sites More sharing options...
Tomas LT Posted January 22, 2015 Author Share Posted January 22, 2015 where you added this code? perhaps in some foreach loop and this is why you see it 2 times I add this code in product.tpl file. Not in other foreach loop. I test different positions in top, middle or end file, but tags displaying two times. Link to comment Share on other sites More sharing options...
Tomas LT Posted February 3, 2015 Author Share Posted February 3, 2015 up Link to comment Share on other sites More sharing options...
razaro Posted February 3, 2015 Share Posted February 3, 2015 Maybe tags are shown twice because of 2 languages ? Try this code <ul class="producttags"> {foreach from=Tag::getProductTags(Tools::getValue('id_product')) key=k item=v} {foreach from=$v key=lang_id item=value} {if $cookie->id_lang eq $lang_id} <li><a href="{$link->getPageLink('search', true, NULL, "tag={$value|urlencode}")}">{$value|escape:html:'UTF-8'}</a></li> {/if} {/foreach} {/foreach} </ul> Link to comment Share on other sites More sharing options...
Tomas LT Posted February 7, 2015 Author Share Posted February 7, 2015 Thank you Link to comment Share on other sites More sharing options...
Tomas LT Posted February 8, 2015 Author Share Posted February 8, 2015 Dont work Showing first tag two times... Link to comment Share on other sites More sharing options...
vekia Posted February 9, 2015 Share Posted February 9, 2015 Dont work Showing first tag two times... it's not default behaviour have you tried to use it without language condition ? Link to comment Share on other sites More sharing options...
wakabayashi Posted August 2, 2015 Share Posted August 2, 2015 I added the following code to my tpl file and it works fine: <ul class="producttags"> {foreach from=Tag::getProductTags(Tools::getValue('id_product')) key=k item=v} {foreach from=$v key=lang_id item=value} <li><a href="{$link->getPageLink('search', true, NULL, "tag={$value|urlencode}")}">{$value|escape:html:'UTF-8'}</a></li> {/foreach} {/foreach} </ul> But how can I check if the foreach condition isnt empty? I want something like {if foreach!=empty} code {/if} Link to comment Share on other sites More sharing options...
wakabayashi Posted August 2, 2015 Share Posted August 2, 2015 Ok solved it: {if Tag::getProductTags(Tools::getValue('id_product'))!=""} Code {/if} Link to comment Share on other sites More sharing options...
pedroserapio Posted September 21, 2015 Share Posted September 21, 2015 (edited) Hello wakabayashi. My project is based on PS1.6.1.1 and I'm trying to use your code in product.tpl: {if Tag::getProductTags(Tools::getValue('id_product'))!=""} <ul class="producttags"> {foreach from=Tag::getProductTags(Tools::getValue('id_product')) key=k item=v} {foreach from=$v key=lang_id item=value} <li><a href="{$link->getPageLink('search', true, NULL, "tag={$value|urlencode}")}">{$value|escape:html:'UTF-8'}</a></li> {/foreach} {/foreach} </ul> {/if} The first conditional if it's working correctly. But I'm getting all the tags without any language filtration. Looks like the key=lang_id it's ignored. Is there any new way in PS1.6.1.1? My best regards. Edited September 21, 2015 by pedroserapio (see edit history) Link to comment Share on other sites More sharing options...
pedroserapio Posted September 21, 2015 Share Posted September 21, 2015 Found the solution in https://www.prestashop.com/forums/topic/469576-tags-in-product-list-16/ {if Tag::getProductTags(Tools::getValue('id_product'))!=""} <ul class="producttags"> {foreach from=Tag::getProductTags(Tools::getValue('id_product')) key=k item=v} {if $k != $lang_id} {continue} {/if} {foreach from=$v item=value} <li><a href="{$link->getPageLink('search', true, NULL, "tag={$value|urlencode}")}">{$value|escape:html:'UTF-8'}</a></li> {/foreach} {/foreach} </ul> {/if} 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