Exclude certain items in a collection from being filtered when a condition applies?

Hello, is it possible to exclude certain items in a collection list from being filtered in case a certain condition applies?

I have filters for countries but for some resources I want to just set them as global so they should show up if any country filter is applied.

currently the content editor has to click and link all countries in order for this resource to show up when any country filter is applied.

assuming I added toggle field in the CMS for them to just mark some resources as global can I exclude those from being filtered by country?

so these resources will have a tag “global” for example and they should always show up even if I applied any country filter.

Hey @logins! I’m afraid there is no simple workaround at the moment. We could use the Static to Collection List Attribute but there is a current bug where we need to set the item to interactive as not doing so drops some items.

If these items do not change much, we could write some code with the API to add these elements always

  /**
   * Adds a static item to the Collection Instance.
   * @param itemsData An array of static items data.
   * @param itemsData.itemElement The new item to store.
   * @param itemsData.targetIndex The index where to place the new item.
   * @param itemsData.interactive Defines if the item will be interactive or not.
   */
  addStaticItems(
    itemsData: Array<{ itemElement: HTMLDivElement; targetIndex: number; interactive: boolean }>
  ): Promise<void>;

Let me know if you want to go this route! If so please share a link!

Thanks @Support-Luis for getting back to me. actually I implemented what I wanted with a simple trick using the value of the switch field from my CMS.

<div class="resource-category">
    <div class="tag-label">Country</div>
    <div class="global-resource">
        <div class="text-size-small">Global</div>
    </div>
    <div class="w-embed w-script">
        <script>
            // Add the countries list to the global resource
            if (true) { // replace true by the CMS switch field ^^
                document.currentScript.parentNode.appendChild(document.querySelector('.countries-list-for-global'));
            }
        </script>
    </div>
</div>
1 Like

Thanks for sharing!

1 Like