How can I have a list with several levels of nesting?

An example of several levels of nesting can be seen using countries as each country has several states and these states have several cities each, here is how we set it up:

The first step is to add the CMS Nest Script to your page <head>

CMS Nest Script

Once you add and style your first parent list we can add the fs-cmsnest-element = list attribute to our list and add an empty div that will be the target of our first list.

fs-cmsnest-element = list

CMS Nest requires the items in the list to have a link to the current item, we can add this link with a link block used as a wrapper if we want the users to navigate to the item’s page or as a hidden link if the users are not meant to move from the page. For this tutorial, we will be using a link block.

Current Link

Once the link to the current item is set we can add the fs-cmsnest-element = nest-target and the fs-cmsnest-collection = IDENTIFIER attributes to our empty divs

fs-cmsnest-element = nest-target (states collection)

fs-cmsnest-collection = state (states target div)

We can now add the collection of states that will be nested in the target divs, this collection requires a link that links to the current item. We can use the same approach of using a link block or hidden link.

Current Link (States Collection)

Once the link is added we can add the fs-cmsnest-element = nest-source and fs-cmsnest-collection = IDENTIFIER to our collection list.

fs-cmsnest-element = nest-source (States Collection)

fs-cmsnest-collection = state (States Collection)

Moving to the template page for the parent collection we need to add the referenced collection, this step is critical as adding the wrong collection will have all the items in the collection nested in our parent collection, be sure to double-check that only the referenced items are visible in the template page.

Country Template Page Referenced Collection

This collection will also need a link to the current item

Current Link (Country Template Page)

And finally we can add the needed attributes to the list on the template page, these attributes will be fs-cmsnest-element = template-reference and fs-cmsnest-collection = IDENTIFIER.

fs-cmsnest-element = template-reference (Country Template Page)

fs-cmsnest-collection = state (Country Template Page)

We can now publish and test our first level of nesting.

Publish and Test First Level

On our state collection, we can add the attributes fs-cmsnest-element = list to our list wrapper.

fs-cmsnest-element = list (States Collection Wrapper)

We will now treat this collection as the parent collection and add a blank div with the fs-cmsnest-element = nest-target and fs-cmsnest-collection = IDENTIFIER that will nest the items for another collection. We already have the link to the current item so we can skip that step.

fs-cmsnest-element = nest-taget (Cities Collection)

fs-cmsnest-collection = city (Cities Target Div)

Add your third list to the page (we add the cities collection), add the link to the current item, and add the attributes fs-cmsnest-element = nest-source and fs-cmsnest-collection = IDENTIFIER to the list

Current Link (Cities Collection)

fs-cmsnest-element = nest-source (Cities Collection)

fs-cmsnest-collection = city (Cities Collection)

Move into the template page for this collection’s parent and add the referenced list as before

Referenced Collection List (State Template Page)

Set the link to the current item in this collection’s items

Current City Link (State Template Page)

Add the attributes fs-cmsnest-element = template-reference and fs-cmsnest-collection = IDENTIFIER to the list

fs-cmsnest-element = template-reference (State Template Page)

fs-cmsnest-collection = city (State Template Page)

To hide the collections that will be nested we can wrap them in a div and hide this div. We should never hide the list wrapper or list on its own as this will cause the list not to show up on our published site. (We use the template page as example but this can also be done also in the main page if you need to)

Hide Parent Divs

Publish and test!

Publish and Test