How to filter a CMS to only show Unique values

Hi everyone!

I have a CMS collection of companies and a field that has the flag image of where they’re based.

I want to show the a CMS collection on page that has all of the flag icons. That’s pretty straightforward, however there are multiple companies in some countries which means that some flags show up multiple times.

Is there anyway to have a CMS only show a flag once?

  • Adam

Here is my site Read-Only: LINK
(how to share your site Read-Only link)

Yes! By using the appropriate structure for your CMS, i.e. using the CMS as it should be.

You often have a main collection, as here it’s your Companies collection. When you set your collection, every time you deal with a repeatable data (a data that could be similar for several items) or a data that you’ll want to use on another collection, or treat as a collection, then you can/need create a collection just for it, and use a reference to it in your main collection.

Here that means you create a collection for countries, with a name field,; a flag image field, and any other field you’d like to use later on. Then you create a Reference field in the Countries collection.

Now it’s going to be easy to list all countries, and you’ll even have template page for countries where you can list all the companies in that country.

Other fields that could be collections: category of activity etc.

1 Like