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

how to set a Default value inside an Reference component provided using data-sly-resource

Avatar

Avatar
Validate 1
Level 1
samikshaa223429
Level 1

Likes

0 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Give Back
View profile

Avatar
Validate 1
Level 1
samikshaa223429
Level 1

Likes

0 likes

Total Posts

35 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Give Back
View profile
samikshaa223429
Level 1

30-06-2020

hi ,

 

I have a component which uses an reference component embedded inside the main component. I am using AEM 6.5 . 

<sly data-sly-resource="${'experiencefragment' @ resourceType='cq/experience-fragments/editor/components/experiencefragment'}"></sly>

I need to define default values to the fragmentPath inside the experience fragment. I tried using the approach provided under 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/default-value-in-reference... , i.e using cq:template and cq:templatePath approach and it fails . 

 

STEPS : 

1. Created a node inside the component of type nt:unstructured called cq:template. Added a property called fragmentPath of type String to it with default value for XF path. 

2. Created a sling:folder outside the component called templateConfigs, created node of type nt:unstructured inside it called experienceFragment . Added a property to it called fragmentPath of type String. Then added a property to component called cq:templateType (String) and added path of the new config as its value.

 

Both above approaches did not work. Please help.

 

Thanks,

Samiksha,

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
MVP
Theo_Pendle
MVP

Likes

238 likes

Total Posts

251 posts

Correct Reply

105 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile

Avatar
Validate 1
MVP
Theo_Pendle
MVP

Likes

238 likes

Total Posts

251 posts

Correct Reply

105 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 10
Ignite 1
View profile
Theo_Pendle
MVP

01-07-2020

Hi @samikshaa223429,

@Arun_Patidar beat me to the punch 😉 But his answer is correct! One thing to know is that the value is cq:template are set when a component is created. That means if you placed your component on the page, then modified the cq:template values, you would have to remove and add the component again to see the changes, maybe that is your problem? 🙂

Other things to look out for:

  • The cq:template child must have the same name as the name of the resource in your data-sly-resource attribute (ie: experiencefragment)
  • The property you want to set a default for must match the name of that property in the target resourceType (ie: fragmentPath)

Here's a quick GIF to prove it works:

Peek 2020-07-01 12-45.gif 

Answers (1)

Answers (1)

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,429 likes

Total Posts

3,300 posts

Correct Reply

937 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,429 likes

Total Posts

3,300 posts

Correct Reply

937 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

30-06-2020

Create a node inside the component of type nt:unstructured called cq:template. Add a child node experiencefragment type of nt:unstructured and add a property called fragmentPath of type String to it with the default value for XF path.