Answer the question
In order to leave comments, you need to log in
How to make nested categories in cnc using nested set yii2?
Good day!
I'm trying to figure out how to correctly implement a url-cnc with infinite nested categories when building a tree through a nested set in Yii2 using https://github.com/creocoder/yii2-nested-sets.
There were no problems with the implementation of the tree in breadcrumbs, we managed to display the path with nesting quite quickly and as needed. There can be any nesting: we find the pages and then all the parents and display them.
For url, the original idea was the same: each page has its own alias or slug, for example:
1) service page: slug - uslugi
2) service page-> some type of service: slug - kakoy-to-vid-uslug
And then, according to the breadcrumb scheme, we find the desired page, through foreach we find all the parents, and then we form everything in the url. For example, if the page is "some kind of service" and the parent is "services", then the url would be uslugi/kakoy-to-vid-uslug.
The question is that I don’t understand how to write it in my own createUrl and parseRequest class. I do not understand how to combine the slug found and the slug of all parents. I can't find any examples.
From the examples found, including the documentation, it only turned out to make a url like: site/zdes-chto-ugodno/slug. That is, for the examples above, it will turn out: 1) site/zdes-chto-ugodno/uslugi and 2) site/zdes-chto-ugodno/kakoy-to-vid-uslug
And in general, is such an approach in the form of a theory for a nested set correct, or is it done in a different way altogether. Maybe in the slug, when creating the page, the entire path is generally saved, based on their selected parent. That is, for a page of some service, not kakoy-to-vid-uslug is saved, but the full view, including the uslugi/kakoy-to-vid-uslug parent?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question