Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Custom component - storing value at template level - data-sly-resource

Avatar

Avatar
Validate 1
Level 2
nitinjl
Level 2

Likes

6 likes

Total Posts

62 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 5
View profile

Avatar
Validate 1
Level 2
nitinjl
Level 2

Likes

6 likes

Total Posts

62 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 5
View profile
nitinjl
Level 2

15-12-2020

Hi,

 

1. Creating custom component as ("section component") and adding text field ("sectionText") using data-sly-resource
2. Adding this component to editable template,
3. Creating a page using this template, but while editing any content into "sectionText", it is getting stored into template level, not at the page level.

Am I missing anything into the code, please suggest

Section Component code -
======================================================================================
<div

data-sly-use.template="core/wcm/components/commons/v1/templates.html"
id="cmp-psppSection" class="cmp-psppSection">

<div data-sly-resource="${'sectionText' @ resourceType = 'core/wcm/components/text/v2/text'}"></div>
</div>

<sly
data-sly-call="${template.placeholder @ isEmpty = true, classAppend='cmp-psppSection'}"></sly>

=======================================================================

 

section_component_issue.JPG

Any suggestions please.. 

 

Thanks

Adobe Experience Manager AEM Custom component data-sly-resource

Accepted Solutions (0)

Answers (1)

Answers (1)

Avatar

Avatar
Affirm 100
MVP
shelly-goel
MVP

Likes

243 likes

Total Posts

409 posts

Correct Reply

104 solutions
Top badges earned
Affirm 100
Give Back 25
Ignite 3
Give Back 10
Validate 1
View profile

Avatar
Affirm 100
MVP
shelly-goel
MVP

Likes

243 likes

Total Posts

409 posts

Correct Reply

104 solutions
Top badges earned
Affirm 100
Give Back 25
Ignite 3
Give Back 10
Validate 1
View profile
shelly-goel
MVP

20-12-2020

@nitinjl 

The code snippet you've shared looks alright. The possible reason for 'sectionText' to be stored under 'structure' in template could be that you added this component in editable template (structure mode) > unlocked it > added text in 'initiial content' mode > then locked back the component in 'structure' mode. In this case the text would be stored under 'structure' node.

To get it stored under the page node, you would have to unlock this component in 'structure' mode and then go to the page and edit/ add the text and then check in crxde - it should be stored under the page node.

In case you're still facing issue, try deleting this component from the template and add it back, unlock and create a new page to add this text. Also try adding a different text in this component in another page (created from same template) - if each page has different text, then what value is stored under 'structure' node?

You would be able to resolve it some template clean up mostly.