Showing a category list on a product page

  • Posts: 25
  • Thank you received: 1
11 years 3 months ago #119274

-- HikaShop version -- : 2.1.3
-- Joomla version -- : 3.1.5
-- PHP version -- : 5.4.10
-- Browser(s) name and version -- : Chrome 28

Hi, I want to display a category menu on a sidebar for the product page. I'm running an antiques website and the categories of the products are like:
Textiles
- Bags
- - Subcat #XXX
- - - Product from subcat #XXX
- - Product from Bags...
- Shawls
- Ponchos
Masks
- Subcategory...

I'm building custom joomla templates for all these. I want to display a sidebar on the left for every product page. The issue is that I want this sidebar categories always from the categories at level 2. For example, if I'm on the page of the "Product from Bags", I want to display the menu as
Bags
Shawls
Ponchos

And so if I'm in "Product from Subcat #XXX". I managed to do it easily in "Bags", by using the JDocumentRenderer to render a module position as "sidebar-product-"+$product->parent_category_id (pseudocode), and generating a content module for each parent category (Textiles, Masks, and so on). The issue here is with categories deeper (like "Subcategory #XXX"), and product pages. So how can I retrieve the parent category ID at level #2 for categories as well as products?

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
11 years 3 months ago #119427

Hi,

The current product/category id is stored in the cid parameter of the URL.
Once you retrieve it, you can load the categories of the product via a query to the hikashop_product_category table, and for the parents of categories, you can look in the hikashop_category table.

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

  • Posts: 25
  • Thank you received: 1
11 years 3 months ago #119578

Thanks, I'll try that

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

Time to create page: 0.061 seconds
Powered by Kunena Forum