Fetching Parent Page Properties from Experience Fragment Component | Community
Skip to main content
Level 2
February 22, 2021
Solved

Fetching Parent Page Properties from Experience Fragment Component

  • February 22, 2021
  • 1 reply
  • 2580 views

Hi All,
I have a header component which uses a experience Fragment and in this XF i have a header component mapped. This Experience Fragment is been used inside my home page editable template. Now i am trying to access a page properties from my home page inside this header component mapped to Experience Fragment

Page Template > XF > Header Component(Access Page Properties).

Below is my code inside the header component model

@1961677 Resource resource; @PostConstruct protected void init() { try { InheritanceValueMap iProperties = new HierarchyNodeInheritanceValueMap(resource); String value = iProperties.getInherited("txPath",String.class);
I am always getting null value for txPath. I had checked the property value under /content/myprj/us/en/jcr:content and the value of txPath exists.
I am not sure whether i can access the property of a page from experience fragment component since both follows a different /content path(Not hierarchy).
Suggest Please

 

 

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 Anudeep_Garnepudi

@rajaram33 

To get current page properties, you can use pageProperties object in any of the component. All the properties of current page will be set pageProperties global object while sling resolves the resource and will be passed along all the resources in the page.

To get inherited pages properties, you can use inheritedPageProperties object. 

You can directly use these objects in HTL or can inject in Sling Model.

1 reply

Anudeep_Garnepudi
Community Advisor
Anudeep_GarnepudiCommunity AdvisorAccepted solution
Community Advisor
February 22, 2021

@rajaram33 

To get current page properties, you can use pageProperties object in any of the component. All the properties of current page will be set pageProperties global object while sling resolves the resource and will be passed along all the resources in the page.

To get inherited pages properties, you can use inheritedPageProperties object. 

You can directly use these objects in HTL or can inject in Sling Model.