Back to category in product page

  • Posts: 65
  • Thank you received: 4
  • Hikashop Business
1 week 3 days ago #367933

-- url of the page with the problem -- : www.fh1881.ch
-- HikaShop version -- : 6.0.0
-- Joomla version -- : 5.2.1
-- PHP version -- : 8.2
-- Browser(s) name and version -- : All

Hi,
I need to create a "back tu category" link in the product page. I've made this script and it works:

<div class="back"><a href="javascript:history.back()">< Back to
<?php
foreach($this->categories as $category){
echo ($category->category_name);
}
?>
</a> </div>

and it works, but I'd like to replace the "history back" javascript with a PHP code that call the real category of the product.

Thank you
Nicolò

Please Log in or Create an account to join the conversation.

  • Posts: 84147
  • Thank you received: 13651
  • MODERATOR
1 week 3 days ago #367937

Hi,

The thread here explains how to have a link with the category of the product:
www.hikashop.com/forum/4-how-to/64957-ca...ts-pages.html#180409

Please Log in or Create an account to join the conversation.

  • Posts: 65
  • Thank you received: 4
  • Hikashop Business
1 week 3 days ago #367938

Hi,
it partialy works but it creates a wrong URL.
It creates:

mlm.undercon.it/component/hikashop/borchie

instead of:

mlm.undercon.it/catalogo/borchie

Thank you

Please Log in or Create an account to join the conversation.

  • Posts: 84147
  • Thank you received: 13651
  • MODERATOR
1 week 2 days ago #367944

Hi,

Then, instead of the line:

echo '<a href="'.hikashop_contentLink('category&task=listing&cid='.$category->category_id.'&name='.$category->alias,$category).'">'.($category->category_name).'</a> - ';
use:
echo '<a href="'.hikashop_contentLink('category&task=listing&Itemid=xxx&cid='.$category->category_id.'&name='.$category->alias,$category).'">'.($category->category_name).'</a> - ';
where xxx is the id of the "catalogo" menu item.

Please Log in or Create an account to join the conversation.

  • Posts: 65
  • Thank you received: 4
  • Hikashop Business
1 week 2 days ago #367953

Hi,
it works but there is another little issue in multilanguage site. The name of the category in the product page is in the main language and not translated.
Thank you

Please Log in or Create an account to join the conversation.

  • Posts: 84147
  • Thank you received: 13651
  • MODERATOR
1 week 2 days ago #367957

Hi,

Change it to:

echo '<a href="'.hikashop_contentLink('category&task=listing&Itemid=xxx&cid='.$category->category_id.'&name='.$category->alias,$category).'">'.hikashop_translate($category->category_name).'</a> - ';

Please Log in or Create an account to join the conversation.

  • Posts: 65
  • Thank you received: 4
  • Hikashop Business
1 week 1 day ago #367973

It seems perfect, thank you.

Please Log in or Create an account to join the conversation.

Time to create page: 0.071 seconds
Powered by Kunena Forum