-
-
Notifications
You must be signed in to change notification settings - Fork 541
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] Fix collection taxonomy/term URL #10439
base: 5.x
Are you sure you want to change the base?
Conversation
If the collection doesn't have a mount, it doesn't have a URL.
I don't believe we say anywhere that the collection url would fall back to the handle anywhere. If you want the taxonomies to have the appropriate collection urls, make it so by mounting the collection. Is there a reason you want or need to make this work without adding a mount to the collection? |
Nevermind all that, sorry. I see that it does work in some cases without being mounted. 🤐 |
The only incorrect behavior I can see on the 5.x branch is that for a taxonomy with a collection, the uri will not include the collection handle when the collection doesn't have a mount. Terms have the correct uris. e.g. // $blog has a mount
$blog->mount(); // Entry at /the-blog
// $articles doesnt
$articles->mount(); // null
$taxonomy->collection($blog)->uri(); // /the-blog/tags ✅
$taxonomy->collection($articles)->uri(); // /tags ❌, should be /articles/tags - this PR is fixing this.
$term->collection($blog)->uri(); // /the-blog/tags/foo ✅
$term->collection($articles)->uri(); // /articles/tags/foo ✅ Even visiting I don't think we really need to ever bother with that new check "is assigned to collection". I think it's ok to assume that the collection you pass to the taxonomy will be one it's assigned to. I'm happy to make the changes since I'm in here but I just wanted to make sure I'm understanding what you were trying to solve. |
The reason I've used I also wanted to align the implementation with #10438 that also uses But you're right, we could technically get away with just checking for |
This PR fixes an issue where a taxonomy or term with attached collection would return the wrong URL if the collection didn't have a mount. It does so by providing the collection handle as a fallback, which aligns with the taxonomy routing docs.
If a collection has a mount, the mount URL will be used and …
/{collection-url}/{taxonomy-slug}
/{collection-url}/{taxonomy-slug}/{term-slug}
If a collection has no mount the collection handle will be used and …
/{collection-handle}/{taxonomy-slug}
/{collection-handle}/{taxonomy-slug}/{term-slug}