Ray UK Posted September 18 Share Posted September 18 (edited) Hi, Im running PS 8.1.7. So Ive decided to use the tags feature as found in Product/Options/Tags. Ive managed to get the tags to show on the product page as follows But when I click, say the "3 for £30" tag, it will go to /search?tag=3+for+£30 but shows no results. Also, how do I go about saying "If tag exists {code to display tag}" so that an empty tag isnt showing on every product. for example, if !exists="tag" Any Ideas on how to get these working. Thanks Edited September 30 by Ray UK (see edit history) Link to comment Share on other sites More sharing options...
Ray UK Posted September 23 Author Share Posted September 23 Does this tag function, not function anymore ? There doesn't seem to be a "Tag block" module any more, and the tag search doesn't work either. Link to comment Share on other sites More sharing options...
Ray UK Posted September 23 Author Share Posted September 23 This is what I currently have. {if $product.tag|@count > 0} <ul class="tags"> {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} Its the first line that must be wrong. Maybe I need to count the tags and put them in a variable so I can just use it like this. {if $producttagcount > 0} Link to comment Share on other sites More sharing options...
Andrei H Posted September 23 Share Posted September 23 Hello, The 'Tag' functionality should still work as expected as stated in the documentation, but the official 'Tag block' module seems to be achieved for quite some time now as you can see in the official public repository Did you display these tags through a custom module/custom code? From what I can see, the structure for the search tag should be the normal one (eg /search?controller=search&s=Zero+Nicotine), not /search?tag=Zero+Nicotine The smarty template code does look good. You would want to debug that $product.tag to see what it contains, maybe it has an empty element, thus count being 1, instead of 0 Link to comment Share on other sites More sharing options...
Ray UK Posted September 23 Author Share Posted September 23 Hi Andrew, thanks for your reply. I have only added that above code to my product.tpl. If I remove the “if statement” then the rest of the code does show the tag correctly and makes those links, ie “/search?tag=3+for+£30” But it showss an empty tag, when the product has not tags. Link to comment Share on other sites More sharing options...
Andrei H Posted September 27 Share Posted September 27 Hello, Sorry for the delay. Does the following code work for you? {if Tag::getProductTags(Tools::getValue('id_product'))} <ul class="tags" style="text-align: right"> {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, "controller=search&s={$value|urlencode}")}"> {$value|escape:html:'UTF-8'}</a></li> {/foreach} {/foreach} </ul> {/if} I think it should work fine for 'Zero Nicotine'. For '3 for £30' it does not seem to work. I think it is because it contains too few letters. 1 Link to comment Share on other sites More sharing options...
Ray UK Posted September 28 Author Share Posted September 28 15 hours ago, Andrei H said: Hello, Sorry for the delay. Does the following code work for you? {if Tag::getProductTags(Tools::getValue('id_product'))} <ul class="tags" style="text-align: right"> {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, "controller=search&s={$value|urlencode}")}"> {$value|escape:html:'UTF-8'}</a></li> {/foreach} {/foreach} </ul> {/if} I think it should work fine for 'Zero Nicotine'. For '3 for £30' it does not seem to work. I think it is because it contains too few letters. Thank you Andrei, the "if" statement is working fine now, and the search is also working fine. The word "for" was in the fuzzy search word list to ignore so I removed that and it worked but showed lost of results so I changed that tag to "3-for-£30" and its working fine. (https://www.northwestecigs.uk/disposable-vapes/558-1786-lost-mary-bm6000-disposable-vape-2-nic-salt.html#/432-flavour-banana_volcano) Many thanks 1 Link to comment Share on other sites More sharing options...
Divine Posted September 30 Share Posted September 30 Hello, Don't forget to edit your first post and add [ Solved] in the title 1 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