cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x] Add routes control (and localization) to taxonomies

Open ryanmitchell opened this issue 11 months ago • 5 comments

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: Screenshot 2023-08-25 at 14 15 27

And allows them to be localized: Screenshot 2023-08-25 at 14 15 30

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.

ryanmitchell avatar Aug 25 '23 13:08 ryanmitchell

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.

godismyjudge95 avatar Oct 04 '23 13:10 godismyjudge95

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.

ryanmitchell avatar Oct 04 '23 13:10 ryanmitchell

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 avatar Nov 08 '23 22:11 godismyjudge95

@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.

ryanmitchell avatar Nov 09 '23 10:11 ryanmitchell

I too, am a fan of the idea of being able to customize my taxonomy routes.

isaackearl avatar Mar 30 '24 18:03 isaackearl

@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 avatar Jul 04 '24 18:07 aerni

@aerni it doesn’t remove it but allows you to do something instead of it

ryanmitchell avatar Jul 04 '24 18:07 ryanmitchell

@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 avatar Jul 04 '24 19:07 aerni

@aerni doesn't seem to conflict

ryanmitchell avatar Jul 08 '24 18:07 ryanmitchell