Console
FunctionsCanopy

canopy.childList

The canopy.childList function returns the child blocks of a Canopy Nested Block for use in a custom loop.

{% for child in canopy.childList() %}

The function is available inside a parent block's template section and returns the block's children, in the order editors arranged them, for full control over the surrounding markup. Each child has the following properties:

PropertyDescriptionData Type
idThe child block's identifierString
templateThe name of the child's block templateString
settingsThe child's setting valuesObject
htmlThe child rendered with its own block templateString

canopy.childList renders are display-only: they do not create the editable zone in the Canopy editor. Include one plain canopy.children() call wherever editors should manage children visually.

Example

A summary strip built from the children's settings, followed by the editable content:

{% canopy template %}
<nav class="flex gap-4 text-sm">
  {% for child in canopy.childList() %}
    <a href="#item-{{ loop.index }}">{{ child.settings.caption }}</a>
  {% endfor %}
</nav>
<div class="grid grid-cols-3 gap-4">
  {{ canopy.children() }}
</div>
{% endcanopy %}

Last updated on

On this page