cms icon indicating copy to clipboard operation
cms copied to clipboard

Can't filter by linked entries in multisite setup

Open goellner opened this issue 4 years ago • 12 comments

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

  1. Add collection productions
  2. Add collection shows with an entry field where you set max items to 1 and the collection to productions
  3. create a template with the collection tag from above
  4. create at least a second locale
  5. 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

goellner avatar Apr 14 '21 13:04 goellner

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

goellner avatar Apr 15 '21 09:04 goellner

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 :)

yobottehg avatar Jan 28 '22 08:01 yobottehg

@jasonvarga Any update about this issue? It is still relevant in version 5.

justkidding96 avatar Jul 31 '24 06:07 justkidding96

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

duncanmcclean avatar Aug 09 '24 19:08 duncanmcclean

+1

justkidding96 avatar Sep 09 '24 15:09 justkidding96

+1

maartenvanhunsel avatar Oct 21 '24 09:10 maartenvanhunsel

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)

sheldonkotyk avatar Jan 10 '25 17:01 sheldonkotyk

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

danielreales7 avatar Mar 18 '25 08:03 danielreales7

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.

danielreales7 avatar Mar 18 '25 09:03 danielreales7

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.

sheldonkotyk avatar May 07 '25 21:05 sheldonkotyk

Any news on this? I've got an angry client.

sheldonkotyk avatar May 20 '25 16:05 sheldonkotyk

We don't have any updates on this one yet, unfortunately. We'll leave a comment when we do.

duncanmcclean avatar May 20 '25 19:05 duncanmcclean

@duncanmcclean any update on this? Or is there a workaround available?

maartenvanhunsel avatar Oct 06 '25 08:10 maartenvanhunsel

@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

MitschF avatar Oct 06 '25 12:10 MitschF