cms
cms copied to clipboard
[5.x] Add routes control (and localization) to taxonomies
You may have something else entirely in mind for this, but I had a bit of free time and thought it worth working on.
This PR adds the ability to specify routes in the taxonomy config:
And allows them to be localized:
Im sure theres stuff I haven't thought through, but hey its a start.
Closes #2403 Closes #2334
Edit:
One of the differences between this and collection routes is that we are trying to make it work for both the 'taxonomy' view and the 'term' view. It occurred to me that we could allow the routes to be more like the collection routes in that the {slug}
could be specified in the route, and we take everything up to /{slug}
as the 'taxonomy' route. I guess another option would be to specify seperate routes for taxonomy and terms.
This PR looks exactly like what I need. Currently having to do an unwieldy Laravel route that does the term/taxonomy fetching, etc.
Am I right in assuming this will prefetch the entries associated with the tax/term? I think currently it does this without customizing the url, just wanted to make sure it doesn't mess it up.
Edit: One of the differences between this and collection routes is that we are trying to make it work for both the 'taxonomy' view and the 'term' view. It occurred to me that we could allow the routes to be more like the collection routes in that the
{slug}
could be specified in the route, and we take everything up to/{slug}
as the 'taxonomy' route. I guess another option would be to specify seperate routes for taxonomy and terms.
I like the semantics of this - being able to specify both the tax archive page and the term archive page.
Am I right in assuming this will prefetch the entries associated with the tax/term? I think currently it does this without customizing the url, just wanted to make sure it doesn't mess it up.
Correct.
I have run into another issue with this setup. Sometimes I want to nest the terms on a page like so:
parent_page/term_name
Perhaps this is a use case that shouldn't be supported by Statamic by default, but in my opinion it would be nice to have as robust routing features for terms as we have for entries.
@godismyjudge95 it still follows the index/show approach, so you could mount it on parent_page/taxonomy_handle/term_name
.
If you want direct mounting, consider using a collection.
I too, am a fan of the idea of being able to customize my taxonomy routes.
@ryanmitchell Does this remove the automatic taxonomy routing? Because I ran into a bug with it and will hold off fixing it if this PR removes it anyway.
@aerni it doesn’t remove it but allows you to do something instead of it
@ryanmitchell You might want to take a look at this PR. Just to ensure we don't conflict. https://github.com/statamic/cms/pull/10398
@aerni doesn't seem to conflict