inheritedPageProperties not available at all child levels

Avatar

Avatar

volgadr10

Avatar

volgadr10

volgadr10

07-02-2021

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.

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

KiranVedantam1992

Avatar

KiranVedantam1992

KiranVedantam1992

07-02-2021

Hi @volgadr10,

 

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.

Answers (0)