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
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
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
Hi @corporate_nomad,
You can use the below approaches -
@HierarchicalPageProperty
provided 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
Best Regards,
Rohan Garg
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.
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
Hi @corporate_nomad
You need to write a clientlibs to fetch the value from parent and shows in the dialog.
It should be similar to cloud config in page properties.
@corporate_nomad Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies