# CMS List Nest: Nested collection lists in Webflow

> Nest more than 100 items and more than 10 nested lists on a page: the multi-reference workaround for Webflow.

- https://www.flowpoweruser.com/attributes/list-nest
- Attribute: `fpu-nest`
- Stable · v1.1.0 · 3,7 kB gzip · free

## The principle · Why List Nest

10 × 100 (Webflow limit) → ∞ (With List Nest)

CMS List Nest copies items into slots inside your parent item, from its template page or from a source list on the same page. As many lists as you like, up to five levels deep. Entirely through fpu-nest attributes.

- **Source**: Template page or source list, supplies the items.
- **Slot**: Div block in the parent item, receives the copies.
- **Order**: As in the source, or as in refs for the slug setup.

## 1. Add this <script> to your project's custom code

Once per project is enough, even if you use the solution on several pages: Project Settings → Custom Code → Head Code. The script loads alongside the page without holding up rendering; it runs once the page is in place and does nothing while no fpu attribute is there.

```html
<!-- FlowPowerUser · CMS List Nest -->
<script defer src="https://cdn.jsdelivr.net/npm/@flowpoweruser/attributes@1/list-nest.js"></script>
```

## 2. Choose the setup and add the attributes

The items reach the slot in one of two ways. Both can be mixed on one page, each slot uses one.

- **Template page — for long lists** (No limit): The list lives on the parent item's template page, bound to its multi-reference field. List Nest loads it, including every following page if it is paginated. No slug text field needed. Costs one request per parent item.

```html
Page with the parent list
└─ Collection Item
   ├─ Link Block   fpu-nest-element="link"   (Current …)
   └─ Div  Slot    fpu-nest-element="target"
                   fpu-nest-collection="name"

Template page of the parent item
└─ Collection List Wrapper   fpu-nest-element="source"
                             fpu-nest-collection="name"
```

- **Slugs — everything on one page** (No extra requests): A source list on the same page supplies the items, a text field with slugs picks them and sets the order. Faster, because nothing is loaded afterwards. A source list shows at most 100 items.

```html
Page with the parent list
├─ Collection Item
│  └─ Div  Slot    fpu-nest-element="target"
│                  fpu-nest-refs="slug-a,slug-b"
│                  fpu-nest-collection="name"
└─ Collection List (hidden)   fpu-nest-element="source"
   └─ Collection Item         fpu-nest-slug="slug-a"
```


### Template page — for long lists: Template page: attributes in the parent item

On the page with the parent list: every parent item gets a link to its template page and a slot that receives the copies.

- **Item link** (`fpu-nest-element="link"`): Points to the parent item's template page. Place a link block, text link or button in the collection item and set it to “Current …” in Link Settings, i.e. the page of this item. It may be hidden.
- **Target slot** (`fpu-nest-element="target"`, `fpu-nest-collection="name"`): The div block inside the parent item that receives the nested items. Give the div block these attributes, but no fpu-nest-refs: that is how List Nest recognises the template page setup. collection names the source list on the template page.
- **Empty state** (`fpu-nest-element="empty"`): Stays in place when there are no matches, otherwise it is removed. Place an element inside the target slot that shows when the list on the template page is empty. When there are matches, the script removes it automatically.

### Template page — for long lists: Template page: the source list

On the collection template page of the parent collection: add a collection list whose source is the parent item's multi-reference field.

- **Source list** (`fpu-nest-element="source"`, `fpu-nest-collection="name"`): The collection list wrapper the items are copied from. Put the attributes on the collection list wrapper, not on the inner collection list. Style the items the way they should appear in the slot. Their order is the output order.

### Slugs — everything on one page: Slugs: attributes on the target page

On the page where the nested list should appear, define the slot that receives the copies.

- **Target slot** (`fpu-nest-element="target"`, `fpu-nest-refs="slug-a,slug-b"`, `fpu-nest-collection="name"`): The div block inside the target item that receives the nested items. Select a div block inside the target item and give it these attributes. target marks the slot, refs lists the slugs to nest (comma-separated, order = render order), and collection names the source collection. collection is optional if only one source exists on the page.
- **Empty state** (`fpu-nest-element="empty"`): Stays in place when there are no matches, otherwise it is removed. Place an element inside the target slot that shows when no referenced items are found. When there are matches, the script removes it automatically.

### Slugs — everything on one page: Slugs: attributes on the source list

Place the source list anywhere on the same page, usually hidden. Its items are cloned into the slots.

- **Source list** (`fpu-nest-element="source"`, `fpu-nest-collection="name"`): The collection list items are cloned from. Select the collection list of the source collection and give it these attributes. After processing, the list is hidden automatically (display:none).
- **Source item** (`fpu-nest-slug="slug-a"`): Each item of the source list carries its slug. Give the collection item the slug it is referenced by in fpu-nest-refs, then bind it to the slug field via CMS.

## 3. Publish and check on the live site

Attributes solutions do not run in Designer, Edit or Preview mode. Publish your project and test the result on the published site, after every change.

## Optional

### More settings

- **Limit** (`fpu-nest-limit="6"`): Maximum number of inserted items per slot. Add this attribute on the target slot to cap the number of inserted items.
- **Keep source visible** (`fpu-nest-hide="false"`): Prevents the source list from being hidden automatically. By default the source list is hidden after processing. With this attribute it stays visible, which helps while building.
- **Logging** (`fpu-nest-logging="true"`): Writes one init line to the console. Logs one line to the browser console on init, which helps while debugging.
- **Global defaults** (`window.fpuListNestConfig`): Sets defaults for all slots via script. Define global defaults in a <script> after the include. An attribute on the element always wins over the global value. Example: window.fpuListNestConfig = { limit: 6, logging: false, hideSource: true }

## Additional features

- **Programmatic API** (`window.fpuListNest`): window.fpuListNest exposes instances, init(), refresh() and destroyAll(), e.g. to re-nest after your own CMS loading.
- **Events** (`fpu:items-changed`): fpu:items-changed fires per populated target list (detail: { solution: 'nest', list }). Conversely, List Nest reacts re-render-tolerantly to events from other solutions (Load More, Filter) and refills new slots automatically.
- **Multi-level nesting**: Source items may contain slots themselves; nesting is resolved up to depth 5 (which also guards against circular references).
- **Note: interactions & IDs**: Source items are cloned (cloneNode), since several targets can use the same source. Webflow interactions (IX2) do not survive cloning; id attributes are carried along, so id-based anchors in source items may produce duplicates.

## Resources

- [View live demo](https://flowpoweruser.webflow.io/attributes/list-nest)
