Reading data stored in separate nodes design dialog | Community
Skip to main content
sreenu539
Level 7
Sep 17, 2020 11:20 PM UTC
Solved

Reading data stored in separate nodes design dialog

Hi,

 

I know to read design dialog values through for example: ${currentStyle.titleType} 

 

But how do you read design dialog data stored as separate nodes below component policy node. 

 

I have a multi field values stored as item nodes below component policy node.

 

I am trying to read it using data sly list ${curentStyle.link} which does not work as link is a child node below component policy node.

i appreciate any help, thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Vijayalakshmi_S
Vijayalakshmi_SAccepted solution
Level 10
Sep 18, 2020 2:29 AM UTC

Hi @sreenu539,

For getting policy programmatically, we need to make use of ContentPolicyManager and ContentPolicy API (We will be able to gain access to ContentPolicyManager from ResourceResolver)

ContentPolicyManager cntPolicyMgr = rescResolver.adaptTo(ContentPolicyManager.class);

Go through the methods exposed by the API and use accordingly. 

We will be able to get the policy and its properties (properties on the policy node). For accessing child nodes under policy node, should be either Resource or Node API. 

ContentPolicyManager API:

ContentPolicy API:

6 replies

Level 3
Jan 19, 2021 7:10 PM UTC
Thank you Sreenu
Translate
sreenu539
sreenu539Author
Level 7
Jan 11, 2021 6:42 PM UTC

@nj2 

I have written a sling model to retrieve parent style node. getAllowedLinks() { allowedLinks = request.getResourceResolver().getResource(currentStyle.getPath()).getChild("links"); return allowedLinks; } in HTL: data-sly-repeat : articleInsightsModel.allowedLinks
Translate
Level 3
Jan 11, 2021 5:22 PM UTC
Hi @sreenu539, I have the same use case, how di you manage to resolve this. Can you please share your solution. Thanks NJ
Translate
Vijayalakshmi_S
Vijayalakshmi_SAccepted solution
Level 10
Sep 18, 2020 2:29 AM UTC

Hi @sreenu539,

For getting policy programmatically, we need to make use of ContentPolicyManager and ContentPolicy API (We will be able to gain access to ContentPolicyManager from ResourceResolver)

ContentPolicyManager cntPolicyMgr = rescResolver.adaptTo(ContentPolicyManager.class);

Go through the methods exposed by the API and use accordingly. 

We will be able to get the policy and its properties (properties on the policy node). For accessing child nodes under policy node, should be either Resource or Node API. 

ContentPolicyManager API:

ContentPolicy API:

Translate
sreenu539
sreenu539Author
Level 7
Sep 18, 2020 4:14 PM UTC

Is there a way to get content resource from sling request - I am trying to use content policy manager to populate data source elements for a dropdown in cq:dialog 

Resource contentResource = resolver.getResource((String) request.getAttribute(Value.CONTENTPATH_ATTRIBUTE));

Value.CONTENTPATH_ATTRIBUTE is displayed as deprecated

 

@vijayalakshmi_s 

Translate