lara96's avatar

How to implement Infinite category tree?

Currently i am developing an eCommerce web application. In that admin should able to add infinite category tree. like this

category1 • sub category • sub sub category • more categories...etc • sub category

In that some fields are only select boxes some are only numbers( such as rooms, vehicle year..etc ) some are alpha numeric. and in posting page according to user selected category value sub categories should be loaded as select boxes or text boxes and it should be saved in post database table it should able to retrieve category details for particular post. Any idea to implement this ?

0 likes
3 replies
lara96's avatar

@PATRICKSJ - Yes for example

vehicle->car->Model->Toyotra

Electronics->Mobile->Model->Samsung

But sub categories' sub category not the same as above example Model sub category

londoh's avatar

I most often use this: https://github.com/lazychaser/laravel-nestedset

Nested sets are an efficient way of getting infinite categories and retrieving associated posts/products/entries/whatever, and this is a mature package for working with them.

downsides: you'll need to build whatever UI you need. slower when lots of writes in large table, but in the type of use case you mention thats not likely to be an issue.

have a read of docs

Please or to participate in this conversation.