Editable Template Is taking Current Design as /etc/design/default | Community
Skip to main content
Level 2
July 8, 2020
Solved

Editable Template Is taking Current Design as /etc/design/default

  • July 8, 2020
  • 3 replies
  • 2335 views

I am trying to set some Clientlibs via the design dialog of the template but its not picking the property. When I further tried to look into PageImpl of the Core bundle found that its reading from currentDesign 

My Page template extended from Core component why its not taking in consideration the policy set in conf node and taking /etc/designs rather as design path. Design dialog property should work as expected with core page component.

Here is the PageImpl of Core Page

https://github.com/adobe/aem-core-wcm-components/blob/master/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/PageImpl.java

And we just creating supertype of Page V2. I can't assume just to access the  getClientLibCategories() we need to re implement the Page and write a logic again.

As I saw documentation on Editable Template clearly says it takes design from Policy node in /conf...

https://docs.adobe.com/content/help/en/experience-manager-65/developing/platform/templates/page-templates-editable.html#layout

 

 

 

 

protected void addPolicyClientLibs(List<String> categories) { if (currentStyle != null) { Collections.addAll(categories, currentStyle.get(PN_CLIENTLIBS, ArrayUtils.EMPTY_STRING_ARRAY)); } }clientLibCategoriesJsHead = currentStyle.get(PN_CLIENTLIBS_JS_HEAD, ArrayUtils.EMPTY_STRING_ARRAY);

 

 

 

 

 

 I tried printing on page currentDesign.path() and its results in /etc/designs/default 

I am not sure how we can take this from the policies. Is there something we need to do in order to get the design from the policy node?

 

I can see the policy node having the property clientlibs and clientlibsJsHead , but I believe it's not being picked as the currentDesign is still pointing to defalt design in /etc. And if I delete /etc/designs/default its picking /libs/settings/wcm/designs/default instead of picking from /conf/<project>/setting...policy

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by RRaj

After debugging further and looking into logs we found the Core Page model object was overridden,  as a custom page model implementing Page model and applied to the same resource type, was written. So the logs saying it cannot find any method in the PageImpl when tried printing. We got this resolved by implementing those methods or, removing that implementation of Page model class. 

 

Thanks @ankur_khare  and @vijayalakshmi_s !!

3 replies

Vijayalakshmi_S
Level 10
July 9, 2020

Hi @rraj,

Policies set for a component can be accessed programmatically using ContentPolicyManager/ContentPolicy API.

In this case, it is the policy of the page component. 

We can use one of the below two ways

  • Using direct policy path from /conf (direct policy path of the page component)

 

Resource policyPath = rescResolver.getResource("/conf/we-retail/settings/wcm/policies/we-retail/components/structure/page/policy_content_page"); ContentPolicy cntPolicyFromResc = policyPath.adaptTo(ContentPolicy.class); ValueMap cntPolicyProps = cntPolicyFromResc.getProperties(); // can access direct property from the valuemap object. (clientlibs/clientlibsJsHead) for(Entry<String, Object> entry : cntPolicyProps.entrySet()) { log.info("Value Map of resc - key={} and value={}", entry.getKey(), entry.getValue()); }

 

  • Using page content resource (which points to the page component - Lets say we-retail/component/structure/page for which the policy is set)

 

ContentPolicyManager cntPolicyMgr = rescResolver.adaptTo(ContentPolicyManager.class); Resource pageCntResc = rescResolver.getResource("/content/we-retail/en/jcr:content"); // argument here can be set dynamically based on the place where we write this code. Eg. Can be retrieved from page object - page.getContentResource() ContentPolicy cntPolicy = cntPolicyMgr.getPolicy(pageCntResc); ValueMap cntPolicyProps = cntPolicy.getProperties(); for(Entry<String, Object> entry : cntPolicyProps.entrySet()) { log.info("Value Map key={} and value={}", entry.getKey(), entry.getValue()); }

 

 

RRajAuthor
Level 2
July 9, 2020

@vijayalakshmi_s I know programmatically it's possible but being a Page template extended from Core component why its not taking in consideration the policy set in conf node and taking /etc/designs rather as design path. Design dialog property should work as expected with core page component.

Here is the PageImpl of Core Page

https://github.com/adobe/aem-core-wcm-components/blob/master/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/PageImpl.java

And we just creating supertype of Page V1. I can't assume just to access the  getClientLibCategories() we need to re implement the Page and write a logic again.

As I saw documentation on Editable Template clearly says it takes design from Policy node in /conf...

https://docs.adobe.com/content/help/en/experience-manager-65/developing/platform/templates/page-templates-editable.html#layout

 

Ankur_Khare
Community Advisor
Community Advisor
July 10, 2020

Did you try to add the clientlib from page properties of aem template?

RRajAuthor
Level 2
July 10, 2020
Hi Ankur, The clientlib from page property, de you mean Advance Tabs Design path field? Then yes, its not accepting /conf ..path
RRajAuthorAccepted solution
Level 2
July 10, 2020

After debugging further and looking into logs we found the Core Page model object was overridden,  as a custom page model implementing Page model and applied to the same resource type, was written. So the logs saying it cannot find any method in the PageImpl when tried printing. We got this resolved by implementing those methods or, removing that implementation of Page model class. 

 

Thanks @ankur_khare  and @vijayalakshmi_s !!