Hi @sudarshanv1 ,
Use Case RecapYou're using a static component (e.g., xyz) inside a loop, but you want:
- Each instance to have independent content (not shared)
- Each to be authorable in AEM
- The component is not dynamic — it's always the same component (prj/components/content/xyz)
HTL Code:<sly data-sly-list.item="${model.items}">
<div data-sly-resource="${'item-' + itemList.count @ resourceType='prj/components/content/xyz'}"></div>
</sly>
Why this Works Perfectly
- ${'item-' + itemList.count} generates unique resource names like:
- item-1, item-2, item-3, etc.
- AEM creates these as child nodes under your component's resource
- Each instance of xyz component is rendered and stored independently
- Authors can edit each block separately in the dialog or page editor
- This avoids shared authoring issues where all entries reflect the same data
Optional Enhancement (for uniqueness across pages/components)
If needed, add a hash of the parent path to avoid clashes:
<sly data-sly-list.item="${model.items}">
<div data-sly-resource="${'item-' + resource.path.hashCode + '-' + itemList.count @ resourceType='prj/components/content/xyz'}"></div>
</sly>
Authoring Dialog Tip
In your dialog, do not hardcode xyz once. Let AEM generate item-1, item-2, etc., and store them automatically during authoring. No multifield needed — each dynamic resource path will behave like a subcomponent.
Regards,
Amit