List Nest - Show grouped items by category

Hello guys,

Is there a way to show a List of topics grouped by the category they have? The solution normally works the other way around where multiple categories added to the item show in the cms item but my approach is a bit different where I need to show all the categories in a list and inside of the cms item of those categories a group of topics that reference that single category show in.

Something similar to this image layout:

Purple are the Category CMS Collection Items

Orange are the Topics CMS Collection and they belong to one of the categories (just one)

Hi @aaron

Sorry just getting to this, how did it go? Did you manage to sort it out on your end?

Hey @aaron!

Perfect! You’re looking to create exactly what CMS Nest was designed for - displaying categories as parent items with their related topics nested underneath. :flexed_biceps:

Here’s how to set it up:

Collection Structure Setup

First, make sure you have:

  • Categories Collection: Your purple category items
  • Topics Collection: Your orange topic items with a reference field pointing to Categories

Implementation Method

Option 1: Default Method (Recommended)
This fetches nested items from template pages automatically:

On your main page (where you want to display the grouped list):

  1. Add the script to your <head>:
<script async type="module" src="https://cdn.jsdelivr.net/npm/@finsweet/attributes@2/attributes.js"></script>
  1. Set up your Categories Collection List:
    • Collection List element: fs-list-element="list"
    • Inside each category item, add a div where topics will appear: fs-list-element="nest-target" and fs-list-nest="topics"
    • Add a link element set to “Current” in Link Settings: fs-list-element="item-link"

On your Categories template page:

  1. Add the Topics Collection List:
    • Collection List Wrapper: fs-list-element="wrapper" and fs-list-instance="topics"
    • Bind this list to a Multi-reference field from your Categories collection (not directly to Topics)
    • Set the collection item link to “Current” in Link Settings

Another approach would be using the single reference field method if your Topics collection has a single reference to Categories. The key difference is your Topics collection references one Category, and the nested list shows all Topics that reference the current Category. :thinking:

If you need help with any custom implementation, @Support-Luis, @Support-Pedro or @jesse.muiruri can assist you further!