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

Add multi-site support to filter options #39

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

taylanunutmaz
Copy link

@taylanunutmaz taylanunutmaz commented Jan 29, 2025

This pull request includes changes to ensure taxonomy queries are filtered by the current site in the HandleStatamicQueries and IsSortable traits. The most important changes include adding the Site facade and modifying methods to include the site filter in taxonomy queries.

@Biostate
Copy link

Your approach works but has some issues. Specifically, in a multi-site project, it uses the translatable slug of a taxonomy. However, my collection stores the taxonomy slug in the default locale.

Example

I have a Projects collection, and I’ve added a Country taxonomy to it. When I attach a country, the collection stores the default locale slug for that country.

USA Country

  • English: slug → usa
  • Turkish: slug → abd

A Project Entry

  • English taxonomy slug: countries: usa
  • Turkish taxonomy slug: countries: usa (Same as English)

Issue

When querying in the Turkish site using "abd", the results won't be found because the project is stored with countries: usa.

Solution

You need to modify the code to always retrieve the taxonomy slug from the default locale:

- $term->slug() => $term->title(),
+ $term->inDefaultLocale()->slug() => $term->title(),

This ensures that the taxonomy slug is consistently fetched from the default locale, preventing mismatches across different site languages.

@afonic
Copy link
Contributor

afonic commented Jan 31, 2025

Thank you for this. Will add some multisite tests in this PR and merge it in the next release.

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.

3 participants