Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!

Inheritance of Custom page property to child pages

Avatar

Level 1

Hi,

 

I have added a custom page property to my page component in the Basic tab. I create a parent page with this template and assign a certain value to the custom prop. Now when I create child pages under the same parent with the same template, I want the custom property to be inherited from parent. (i.e When I open page properties of child I want to see this field pre populated with the value that I have authored in the Parent page ).

 

@arunpatidar @EstebanBustamante @Raja_Reddy @aanchal-sikka 

 

 

Topics

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

3 Replies

Avatar

Community Advisor

Hi @corporate_nomad

You can use the below approaches - 

  1. Using the InheritanceValueMap interface
  2. Using @HierarchicalPagePropertyprovided by ACS Commons. 

You can also refer to the below links for reference -  

AEM inheritedpageproperties with Sightly, JSP, OSGI Bundle

How to Inherit Properties in AEM

Other Queries on Experience League - 
How can I inherit page properties

Page properties inheritance 

Best Regards,
Rohan Garg

Avatar

Level 1

Hi @Rohan_Garg 

 

I appreciate your response. The use case that I am trying to achieve here is as follows. 

 

Currently when an author tries to create a page, along with the Title he has to author an additional filed (tagpicker) which is my custom filed. Business wants to automatically populate this value based on the parent page value. 

 

E.g If on parent page author sets the value of Tag Picker as 'x' then whenever a child page is created the author does not want to re author that value. It is expected to be pre populated from Parent. 

 

I have no issues with fetching the value in my Sling or Sightly code. I just need the property to be in the Page Properties so that it eases authors work.

 

Avatar

Community Advisor

So if you are able to fetch the value say in your sling code then there should be no issue in setting the value. When you are creating that page, the page model class can be used to set the value.

For instance we set the header XF path based on the parent value as shown below - 

@Model(adaptables = SlingHttpServletRequest.class)
public class PageModel {
private String headerXF;

@Inject
InheritanceValueMap pageProperties;

if (null != pageProperties) {
headerXF = pageProperties.getInherited("headerXF", String.class);
   }

You can inject the page property in the sling model and set the value of that property using pageProperties.getInherited("pagePropertyName", String.class);
That should auto populate the value as on page creation the page model will set the property based on inherited values.

I hope this helps!

 

Best Regards,

Rohan Garg