cms
cms copied to clipboard
Can't filter by linked entries in multisite setup
When using an entries field to filter the results in a collection tag, it does not work in a multisite setup.
Example:
A collection shows with an entries field called productions, where the user selects one entry from another collection called shows.
This tag works fine on the default locale, but it shows no results on all other locales.
{{ collection from="shows" :production:is="id" sort="show_date:asc" }}
{{ if no_results }}
no results
{{ else }}
{{ title }}
{{/if }}
{{ /collection }}
It looks like the entries have different ids on all locales. The linked production is not translatable on all other locales, so it only has to be set once.
How to Reproduce
- Add collection productions
- Add collection shows with an entry field where you set max items to 1 and the collection to
productions - create a template with the collection tag from above
- create at least a second locale
- everything is working fine on the default locale, but not on all other locales
Extra Detail
This also applies when trying to do something like this: {{ 'ef2da943-c556-4a0f-9d71-73b37bfad38c' | get:url }} for hardcoded links in a template. This also only works on the default locale, because the entries have different ids. Question: why do the entries need different ids?
Environment
Statamic 3.1.6 Pro Laravel 8.33.1 PHP 7.4.15 jonassiewertsen/statamic-livewire 2.5.0 spatie/statamic-responsive-images 2.5.3 statamic/seo-pro 2.1.5
Install method (choose one):
- Fresh install from
statamic/statamic
I went ahead and set up a demo repo for this bug: https://github.com/goellner/statamic-relations
On the movies detail page, it works in the default locale en but not in the second one de.
Working here: http://statamic-relations.test/movies/lord-of-the-rings Not working here: http://statamic-relations.test/de/filme/lord-of-the-rings
Is there any update on this or a workaround? We ran into the same today and our current workaround would be to create custom tags for the collection listings.
Any insights would be valuable :)
@jasonvarga Any update about this issue? It is still relevant in version 5.
Unfortunatley, I don't have a fix for this.
However, I've created a new example repo on Statamic 5, using @goellner's example, for whenever we get around to looking into this: https://github.com/duncanmcclean/cms-3528
+1
+1
Not sure if this helps at all but I think this may potentially be related.
If I create an entry in a locale (should only exist in that locale), then filter the collection with other collection entries, it won't show up. (it will show up if the filter isn't called).
If I create an entry in the default site then localize it, then unpublish the original, the filtering by a collection entry works on the locale.
Let me know if I need to create a new issue. I'm running 5.45.1 (latest at this time)
The same thing happens to me here:
When I use multisite it doesn't filter the collections by taxonomy
{{ collection:products :locale="site:handle" :taxonomy:product_collections="collection_slug" :taxonomy:product_categories="category_slug" scope="product" }}
<div class="flex flex-col text-center gap-4">
<img src="{{ product:featured_image }}" alt="{{ product:featured_image:alt }}" class="w-full h-auto mx-auto object-cover">
<span class="text-sm md:text-lg lg:text-xl min-h-10">{{ product:title }}</span>
</div>
{{ /collection:products }}
For default site is working, but if I change to english site I can't filter by taxonomy. In the same component:
{{ collection:products scope="product" }}
{{ product:title }}
{{ product:product_categories }}
{{ title }} - {{ slug }}
{{ /product:product_categories }}
{{ product:product_collections }}
{{ title }} - {{ slug }}
{{ /product:product_collections }}
{{ /collection:products }}
I can show taxonomies correctly... it's strange
statamic/cms version = 5.49.1
In case it helps anyone, under content/collections/products/es I have:
id: f3e45b9c-15ac-4dee-8899-dbbb2f3f3c0b blueprint: product title: Adelaida featured_image: coleccion-primavera-verano/camisetas/adelaida.jpg product_collections:
- primavera-verano product_categories:
- camisetas updated_by: d0991f94-737a-4784-8835-bacb3e894932 updated_at: 1741708029
And my product/en have:
id: 510ab52f-00c2-4400-ba4c-88dc294d6130 origin: f3e45b9c-15ac-4dee-8899-dbbb2f3f3c0b updated_by: d0991f94-737a-4784-8835-bacb3e894932 updated_at: 1742286076
If I add here:
id: 510ab52f-00c2-4400-ba4c-88dc294d6130 origin: f3e45b9c-15ac-4dee-8899-dbbb2f3f3c0b updated_by: d0991f94-737a-4784-8835-bacb3e894932 updated_at: 1742286076 product_collections: - spring-summer product_categories: - t-shirts
It's works... It's a bit of a pain to go one by one... but I'll have no choice for now.
I think we've narrowed this down to the filter looking at the default entry ID rather than the localized entry ID. If we change the localized entry ID to be the origin's ID the filter works correctly.
Any news on this? I've got an angry client.
We don't have any updates on this one yet, unfortunately. We'll leave a comment when we do.
@duncanmcclean any update on this? Or is there a workaround available?
@duncanmcclean any update on this? Or is there a workaround available?
I used Query Scopes as a workaround. It's working good so far. Maybe this can help you for now: https://github.com/statamic/cms/issues/11307#issuecomment-2621942254