Jump to content

[SOLVED] Tags link not working properly?


Ray UK

Recommended Posts

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

image.png.49b1ae38ec232b78da6613ffc9b31011.png

But when I click, say the "3 for £30" tag, it will go to /search?tag=3+for+£30 but shows no results.

image.png.0bc472b9d5f5555edf471f3a3a384033.png

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 by Ray UK (see edit history)
Link to comment
Share on other sites

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

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

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

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.

  • Like 1
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

  • Ray UK changed the title to [SOLVED] Tags link not working properly?

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