[Skip to main content](#vessel-content)

#   Right Way to retrieve a category Tree to put in my own made view

##

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

3 years 5 months ago [\#352623](#352623) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  *[Right Way to retrieve a category Tree to put in my own made view](/forum/26-product-category-display/906587-right-way-to-retrieve-a-category-tree-to-put-in-my-own-made-view#352623 "-- HikaShop version -- : 4.7.3 -- Joomla version -- : 4.3.2 -- PHP version -- : 8.2.2  Many years ago we used o-tree when working with HikaMarket to build our custom views.  Nowadays we are building sites only with HikaShop.  We want to make a view in a self-made component that would show a Product Category Tree.  What would be the right, modern way to do this using the already created resources in HikaShop?  Thank you.")* was created by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")*

-- HikaShop version -- : 4.7.3
-- Joomla version -- : 4.3.2
-- PHP version -- : 8.2.2

Many years ago we used o-tree when working with HikaMarket to build our custom views.

Nowadays we are building sites only with HikaShop.

We want to make a view in a self-made component that would show a Product Category Tree.

What would be the right, modern way to do this using the already created resources in HikaShop?

Thank you.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDY1ODctcmlnaHQtd2F5LXRvLXJldHJpZXZlLWEtY2F0ZWdvcnktdHJlZS10by1wdXQtaW4tbXktb3duLW1hZGUtdmlldz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86584
- Thank you received: 14325
-
-

3 years 5 months ago [\#352626](#352626) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Right Way to retrieve a category Tree to put in my own made view](/forum/26-product-category-display/906587-right-way-to-retrieve-a-category-tree-to-put-in-my-own-made-view#352626 "-- HikaShop version -- : 4.7.3 -- Joomla version -- : 4.3.2 -- PHP version -- : 8.2.2  Many years ago we used o-tree when working with HikaMarket to build our custom views.  Nowadays we are building sites only with HikaShop.  We want to make a view in a self-made component that would show a Product Category Tree.  What would be the right, modern way to do this using the already created resources in HikaShop?  Thank you.")*

Hi,

We'll need to know more on the situation to be able to say what the best.
Is it on the frontend, or on the backend ?
Do you need it to be a selector of categories using the category tree, like for example in the "categories" setting of a coupon ?
Or do you need it to be only a list of categoy names, without links, with just some kind of identation made with HTML ?
Or something else ?

In HikaShop, we display the category tree when someone needs to select one or several categories for a restriction option. Having a similar selector elsewhere should be rather easy, especially in the backend. And we also display the category tree for the explorer on the left side of the categories / products listing in the backend. Again, having a similar display in the backend should not be a problem.
For other kind of display, I'm afraid you'll have to do the display on your end. You could probably use the getList method of class.category to load the data of the categories from the database. So it would help a bit.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDY1ODctcmlnaHQtd2F5LXRvLXJldHJpZXZlLWEtY2F0ZWdvcnktdHJlZS10by1wdXQtaW4tbXktb3duLW1hZGUtdmlldz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

3 years 5 months ago [\#352631](#352631) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  Replied by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")* on topic *[Right Way to retrieve a category Tree to put in my own made view](/forum/26-product-category-display/906587-right-way-to-retrieve-a-category-tree-to-put-in-my-own-made-view#352631 "-- HikaShop version -- : 4.7.3 -- Joomla version -- : 4.3.2 -- PHP version -- : 8.2.2  Many years ago we used o-tree when working with HikaMarket to build our custom views.  Nowadays we are building sites only with HikaShop.  We want to make a view in a self-made component that would show a Product Category Tree.  What would be the right, modern way to do this using the already created resources in HikaShop?  Thank you.")*

Hi Nicolas,

thanks for such a quick and extensive attention to our request. I'll try to be as specific as possible.

Main need is for frontend use, for a restricted number of admin users that need to do some stuff from the frontend.
Using in backend is convenient too, specially if it would be the same method.

We need a fully functional tree as when we edit products in backend.

One that unfolds subcategories, that can be default rendered with a certain number of sub-levels, that can trigger the load of its children products in another container / function,

No need to re-organize or delete categories from the same tree.

Any further orientation will be appreciated. In the meanwhile we'll check the getList method you suggest.

Best regards,

Peter

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDY1ODctcmlnaHQtd2F5LXRvLXJldHJpZXZlLWEtY2F0ZWdvcnktdHJlZS10by1wdXQtaW4tbXktb3duLW1hZGUtdmlldz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86584
- Thank you received: 14325
-
-

3 years 4 months ago [\#352637](#352637) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Right Way to retrieve a category Tree to put in my own made view](/forum/26-product-category-display/906587-right-way-to-retrieve-a-category-tree-to-put-in-my-own-made-view#352637 "-- HikaShop version -- : 4.7.3 -- Joomla version -- : 4.3.2 -- PHP version -- : 8.2.2  Many years ago we used o-tree when working with HikaMarket to build our custom views.  Nowadays we are building sites only with HikaShop.  We want to make a view in a self-made component that would show a Product Category Tree.  What would be the right, modern way to do this using the already created resources in HikaShop?  Thank you.")*

Hi,

I'm not sure what you mean by "We need a fully functional tree as when we edit products in backend.". Are you talking about a category selector like the "categories" setting when you edit a product ?
If it's this, you can use code like this: Code:

$this-&gt;nameboxType = hikashop_get('type.namebox'); echo $this-&gt;nameboxType-&gt;display( 'data[product][categories]', // this is the name of the input which you'll be able to access in the $_POST $categories, // this is the value already selected hikashopNameboxType::NAMEBOX_MULTIPLE, 'category', array( 'delete' =&gt; true, 'brand' =&gt; false, 'sort' =&gt; true, 'default_text' =&gt; '&lt;em&gt;'.JText::_('HIKA_NONE').'&lt;/em&gt;', 'tooltip' =&gt; true, ) );

Or are you talking about the category explorer on the left side of the products listing ?
Displaying the explorer can be done with code like this: Code:

$tree = hikashop_get('type.categorysub'); echo $tree-&gt;displayTree('product_listing', 0, array('product','vendor'), true, true, $currentCategoryId, $urlWhereToRedirect);

where $currentCategoryId is the id of the current category and $urlWhereToRedirect contains the URL where you want the explorer to go when a category is selected. It will add to it the parameter &amp;filter_id=xxx where xxx is the id of the category selected.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDY1ODctcmlnaHQtd2F5LXRvLXJldHJpZXZlLWEtY2F0ZWdvcnktdHJlZS10by1wdXQtaW4tbXktb3duLW1hZGUtdmlldz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")**
- [![PeterChain's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar570.png)](/forum/user/570-peterchain "View PeterChain's Profile") Topic Author
- [ Offline](/forum/user/570-peterchain)

Less More

- Posts: 640
- Thank you received: 16
-
-

3 years 4 months ago [\#352662](#352662) by [PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")  Replied by *[PeterChain](/forum/user/570-peterchain "View PeterChain's Profile")* on topic *[Right Way to retrieve a category Tree to put in my own made view](/forum/26-product-category-display/906587-right-way-to-retrieve-a-category-tree-to-put-in-my-own-made-view#352662 "-- HikaShop version -- : 4.7.3 -- Joomla version -- : 4.3.2 -- PHP version -- : 8.2.2  Many years ago we used o-tree when working with HikaMarket to build our custom views.  Nowadays we are building sites only with HikaShop.  We want to make a view in a self-made component that would show a Product Category Tree.  What would be the right, modern way to do this using the already created resources in HikaShop?  Thank you.")*

Thank you, Nicolas,

I believe both solutions are well-suited to our needs.

We'll be in touch should we need further assistance. We appreciate your guidance on these matters.

Best regards,

Peter.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI2LXByb2R1Y3QtY2F0ZWdvcnktZGlzcGxheS85MDY1ODctcmlnaHQtd2F5LXRvLXJldHJpZXZlLWEtY2F0ZWdvcnktdHJlZS10by1wdXQtaW4tbXktb3duLW1hZGUtdmlldz90bXBsPW1hcmtkb3du) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.076 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
