Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

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

Avatar

Level 2

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...

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-temp...

 

 

 

 

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

1 Accepted Solution

Avatar

Correct answer by
Level 2

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

View solution in original post

5 Replies

Avatar

Community Advisor

Hi @rohanr43729387,

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());
		}

 

 

@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...

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-temp...

 

Avatar

Community Advisor

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

Avatar

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

Avatar

Correct answer by
Level 2

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