- Strapi Version: v4.7.0
Lets say we have a hierarchy of categories and then products, so for example:
We are entering slugs for each page like this:
Then we use the […slug].tsx file to fetch the pages based on the full path above. We do it like this because we can’t fetch it based on a single slug because it could be the same in different categories. Its specific to parent/child relationship.
The problem is… if we enter say 200 sub-categories/products under /clothes/ then want to rename /clothes/ slug to something else, we have to edit 200 sub-categories/products to change the /clothes/ part of their slug.
Is there any way to auto create slugs based on the parent (related field), then that parents parents, then that parents parent etc? So when we edit /clothes/ then all the children slugs change too? Otherwise its a bit of a nightmare.
We did also wonder if we use single word slugs, not a path, but in the front end, I am not sure how to construct the query to fetch the correct page based on each segment. I dont know how to query to fetch the parent of the parent of the parent etc. So if you land on /clothes/mens/t-shirts, how can you fetch the correct entry from slug t-shirts, which has related page with slug mens, and then that related page has a related page with slug clothes? Bear in mind it could be a deeper or shallower hierarchy.
A bonus would also be able to show child pages indented under the parent in the admin, so we can easily see which ones are children of what parent.