Hi all,
Scenario : In dialog when I put in the root path, the sling model will fetch the first 4 pages based on recent published date. So now I'm having the paths of the pages ready in the sling model with me. How to fetch some properties from those pages. Like my question is how do I use that path and get required properties of that page?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @arindam6600
Please use the below snippet of code. First, you would have to create the page manager object and with that you can get the Page object by passing the page path. Once it's done, create the valuemap object and get the properties of the page.
PageManager pm = resource.getResourceResolver().adaptTo(PageManager.class);
Page containingPage = pm.getContainingPage(resourceResolver.getResource(pagePath));
ValueMap pageProperties = containingPage.getProperties();
String prop= pageProperties.get("prop1", String.class);
Hope this helps.
Hi @arindam6600
Please use the below snippet of code. First, you would have to create the page manager object and with that you can get the Page object by passing the page path. Once it's done, create the valuemap object and get the properties of the page.
PageManager pm = resource.getResourceResolver().adaptTo(PageManager.class);
Page containingPage = pm.getContainingPage(resourceResolver.getResource(pagePath));
ValueMap pageProperties = containingPage.getProperties();
String prop= pageProperties.get("prop1", String.class);
Hope this helps.
Hi
Please find some of the examples to use the page properties and read from different objects in AEM
https://www.tabnine.com/code/java/methods/com.day.cq.wcm.api.Page/getProperties
Views
Like
Replies
Views
Likes
Replies