inheritedPageProperties not available at all child levels | Community
Skip to main content
Level 2
February 8, 2021
Solved

inheritedPageProperties not available at all child levels

  • February 8, 2021
  • 1 reply
  • 1400 views

I am facing an issue where my custom added property is available to direct children but not grandchildren. For example, I have a property showTitle and its value is set on page 1 and is available on page1.1 but not available on page 1.1.1. I need it to be available in all subpages of the page1. Any ideas on how to achieve that.

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 Kiran_Vedantam

Hi @volga_dharam_rakshika,

 

You can access inheritedPageProperties in different ways:

  1. Sightly: ${inheritedPageProperties.myCustomProperty}
  2. Java: InheritanceValueMap 
    1. Definition as per the documentation: The InheritanceValueMap is an extension of the ValueMap which allows taking the hierarchy of resources into account while looking for properties. As such, if a property is not found on the current resource, it will be looked upon by its parent and so on. The exact inheritance mechanism depends on the implementation.
    2. Sample Code:
      1. @ScriptVariable
        private Page currentPage;
        InheritanceValueMap ivm = new HierarchyNodeInheritanceValueMap(currentPage.getContentResource());
        String inheritedValueMyCustomProperty = ivm.getInherited("myCustomerProperty"String.class);
  3. If it is JSP you can use the same way as Java.

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

1 reply

Kiran_Vedantam
Community Advisor
Kiran_VedantamCommunity AdvisorAccepted solution
Community Advisor
February 8, 2021

Hi @volga_dharam_rakshika,

 

You can access inheritedPageProperties in different ways:

  1. Sightly: ${inheritedPageProperties.myCustomProperty}
  2. Java: InheritanceValueMap 
    1. Definition as per the documentation: The InheritanceValueMap is an extension of the ValueMap which allows taking the hierarchy of resources into account while looking for properties. As such, if a property is not found on the current resource, it will be looked upon by its parent and so on. The exact inheritance mechanism depends on the implementation.
    2. Sample Code:
      1. @ScriptVariable
        private Page currentPage;
        InheritanceValueMap ivm = new HierarchyNodeInheritanceValueMap(currentPage.getContentResource());
        String inheritedValueMyCustomProperty = ivm.getInherited("myCustomerProperty"String.class);
  3. If it is JSP you can use the same way as Java.

 

Hope this helps.

 

Thanks,

Kiran Vedantam.

Level 2
February 8, 2021
Hi @kiran_vedantam, this works fine on author instance but on publish instance InheritedValueMap is not working as expected. It fetches the value from parent only not grandparent.