Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 20 commits into
base: 5.x
Choose a base branch
from

Conversation

ryanmitchell
Copy link
Contributor

@ryanmitchell ryanmitchell commented Aug 25, 2023

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 ryanmitchell changed the title Add routes control (and localization) to taxonomies [4.x] Add routes control (and localization) to taxonomies Aug 25, 2023
@godismyjudge95
Copy link
Contributor

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.

@ryanmitchell
Copy link
Contributor Author

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.

@godismyjudge95
Copy link
Contributor

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.

@ryanmitchell
Copy link
Contributor Author

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

@isaackearl
Copy link

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

@ryanmitchell ryanmitchell changed the title [4.x] Add routes control (and localization) to taxonomies [5.x] Add routes control (and localization) to taxonomies May 10, 2024
@aerni
Copy link
Contributor

aerni commented Jul 4, 2024

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

@ryanmitchell
Copy link
Contributor Author

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

@aerni
Copy link
Contributor

aerni commented Jul 4, 2024

@ryanmitchell You might want to take a look at this PR. Just to ensure we don't conflict. #10398

@ryanmitchell
Copy link
Contributor Author

@aerni doesn't seem to conflict

@fabiangigler
Copy link
Contributor

fabiangigler commented Sep 13, 2024

I came here from #2403, and am looking to define the route as a query parameter to something like this /blog?tag=guide. Will this be supported through this PR?

If not, would there need to be a seperate field to overwrite the URL used for the "Visit URL" button here? For the live preview this is currently already working in v5.
grafik

@ryanmitchell
Copy link
Contributor Author

it would. but this PR has been sitting a long time, I wouldnt rely on it getting merged!

@fabiangigler
Copy link
Contributor

indeed!

@jasonvarga are there any blockers or conflicts preventing this merge here? seems like a very sensible addition.

@robdekort
Copy link
Contributor

Am I right in thinking this PR, together with a future option to make taxonomies mountable (so you can optimize those pages for SEO) would make them great again?

@justkidding96
Copy link
Contributor

@jasonvarga @duncanmcclean Any update on this?

@duncanmcclean
Copy link
Member

Sorry, we don't have an update on this. When we do, we'll update this PR.

@fabiangigler
Copy link
Contributor

Let us know if anything's missing that the community could contribute :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom Taxonomy Routes Localizable Taxonomy Routes
8 participants