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
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Variable value to granite:class

Shubham_borole
Community Advisor
Community Advisor

Hello All,

I am trying to add a dynamic value to a granite:class property. (To be used inside a multifield)

 

<type jcr:primaryType="nt:unstructured"
                          granite:class="unique-class-${requestPathInfo.suffixResource}"
                          sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
.....
</items>
</type>

 

In above eg, ${requestPathInfo.suffixResource} is surely not a variable. however I am looking for something I can use here that would be unique. Does anyone have any idea what else is accessible here? Like RequestPathInfo interface are there any other interfaces available that can be accessed here?

 

Thanks

 

1 Accepted Solution
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Hi,

What is your use case?

if you want to uniquely identified the component from FED, you can do it by calling 'Granite.author.DialogFrame.currentDialog.editable.path'

for dialog ${requestPathInfo.suffix} returns the unique value(authored component path in jcr).

View solution in original post

0 Replies
Arun_Patidar
Correct answer by
Community Advisor
Community Advisor

Hi,

What is your use case?

if you want to uniquely identified the component from FED, you can do it by calling 'Granite.author.DialogFrame.currentDialog.editable.path'

for dialog ${requestPathInfo.suffix} returns the unique value(authored component path in jcr).

View solution in original post

Shubham_borole
Community Advisor
Community Advisor

Thanks a lot for your response.
I am looking to show and hide an item inside a multifield.

So case is I have a multifield with say 3 items. With selection of first two no action required. For selection of third item, I am showing a textfield (required). Now since this is a multifield suppose I author three items. First two with options 1 and 2 (no condition items) and the third multifield item with third option for which the show-texfiield should show up. The issue is since I am using a class name say - ".mytype-showhide" the textfield that should appear for third item appears for all three now since the class is not unique for each multifield item, rather all of the items. I tried using ".mytype-showhide-${requestPathInfo.suffix}" for the 'cq-dialog-dropdown-showhide-target' but that is also same for all three items obviously for eg: mytypeshow-hide-/content/path/to/page/jcr:content/contentArea/mymultifieldcomp_651549243

 

Another option I could try is your solution on this post (https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem6-4-multifield-with-sho...) But I am looking to avoid adding a js for this.

If I could add something to 'cq-dialog-dropdown-showhide-target' on the granite:data node that would by unique for each multifield item seems like it would probably solve the issue. But not sure if that is possible without adding custom js logic. I don't have an insight (or knowledge) about what other interfaces (or other correct term) are available on each multifield item for 'cq-dialog-dropdown-showhide-target' property.

Arun_Patidar
Community Advisor
Community Advisor
Hi, I would still suggest to use https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem6-4-multifield-with-sho... using extraClientlibs so it will not impact anything else. OOTB you can't add the randon class using EL, with javascript yes based on index.
Shubham_borole
Community Advisor
Community Advisor
Thanks a lot for quick response Arun. Will try that out 🙂
Shubham_borole
Community Advisor
Community Advisor
Thanks. The above is what I tried and was trying to get something I could do to have variable class values for multifield items. The above does not seem to work for multifield since one selection applies to all because of same class value.