Expand my Community achievements bar.

SOLVED

Fetching Parent Page Properties from Experience Fragment Component

Avatar

Level 2

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

@Deleted Account 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

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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