- Posts: 25
- Thank you received: 1
Showing a category list on a product page
13 years 1 month ago #119274
by acwilan
Showing a category list on a product page was created by acwilan
-- 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?
-- 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.
13 years 1 month ago #119427
by nicolas
Replied by nicolas on topic Showing a category list on a product page
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.
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.
13 years 1 month ago #119578
by acwilan
Replied by acwilan on topic Showing a category list on a product page
Thanks, I'll try that
Please Log in or Create an account to join the conversation.
Time to create page: 0.149 seconds