we have a multifield and we are iterating them in html using list.
in between iteration im using <div data-sly-resource="${'xyz' @ resourceType='prj/components/content/xyz'}"></div>
but while authoring ill be getting resource xyz to author at one place not in all places.
and same authorable fields are rendered everywhere.
is it a write behavior?
Views
Replies
Total Likes
HI @SudarshanV1 ,
I'd like you t consider few points and then follow the code snippet that I've provided:
This approach allows you to dynamically include resources for each item in a list, leveraging AEM's powerful resource resolution capabilities.
<!-- Assuming you have a list of items in your model -->
<div data-sly-list="${model.items}">
<!-- Each item in the list can be accessed using the currentItem variable -->
<div>
<!-- Render a resource dynamically for each item -->
<div data-sly-resource="${currentItem.resourcePath}" />
</div>
</div>
-Tarun
Views
Replies
Total Likes
resource is not dynamic. its static in my case and im directly adding it with
<div data-sly-resource="${'xyz' @ resourceType='prj/components/content/xyz'}"></div>
Views
Replies
Total Likes
Hi @SudarshanV1 ,
what i understood from replies is, the 'path' of the resource your are including should be unique per each include in the loop.
ex: <div data-sly-resource="${'xyz' @ resourceType='prj/components/content/xyz'}"></div>
in this case the path is always 'xyz'
instead
<div data-sly-resource="${<some dynamic value or take it from each item> @ resourceType='prj/components/content/xyz'}"></div>
the loop outcome can be
<div data-sly-resource="${itm1 @ resourceType='prj/components/content/xyz'}"></div>
<div data-sly-resource="${itm2 @ resourceType='prj/components/content/xyz'}"></div>
.
.
so that you will get multiple entries of same static 'xyz' component with different paths. (i guess this us what your expectation.)
Thanks,
Raju.
Views
Replies
Total Likes
Hi @SudarshanV1 ,
The issue happens because you're using the same resource ('xyz') for each item in the multifield. This makes AEM treat it as a single resource, causing all items to show the same content and not allowing authoring.
To fix the issue, you need to reference a unique resource path for each item in the multifield. This ensures that each item points to its own instance of the component, allowing separate authoring.
<div data-sly-list="${model.items}">
<div data-sly-resource="${item.resourcePath @ resourceType='prj/components/content/xyz'}"></div>
</div>
By doing this, each item in the multifield gets its own unique resource, so it can be authored separately, avoiding the problem of sharing the same resource across all items.
Let me know if it works.
Thanks.
Views
Replies
Total Likes
Hi @SudarshanV1 ,
You may refer
<div class="container ">
<div class="table">
<sly data-sly-list.row="${count.numberOfRows}">
<div class="table-row">
<sly data-sly-list.column="${model.numberOfColumns}">
<sly class="table-cell" data-sly-test.resourceNode="cmp-${resource.path.hashCode}-${rowList.count}${columnList.count}"></sly>
<div data-sly-resource="${ resourceNode,
resourceType='example/components/content/tableLongForm/rte'}"
data-sly-unwrap="${!wcmmode.edit && !wcmmode.preview}" style="min-width:60px;">
</div>
</sly>
</div>
</sly>
</div>
</div>
Thanks
Views
Replies
Total Likes
@SudarshanV1 xyz should be a variable like xyz1, xyz2, etc. in place of constant for all.
Views
Replies
Total Likes
Hi @SudarshanV1 ,
<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
Views
Replies
Total Likes
@SudarshanV1 Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Views
Likes
Replies