Skip to main content
Level 6
Aug 6, 2021 3:03 AM UTC
Solved

Retrieve any custom property from page using HTL

Hello community - is there a way to retrieve any page property other than the component node. i.e I have a component, in that I want to retrieve page's custom property which is not part of component node. I tried the below but it is not working. Can you advise me?

 

${page.getProperties['root/responsivegrid/content/customPropertyName']}

BimmiSoAccepted solution
Adobe Employee
Aug 6, 2021 5:17 AM UTC

Hi @test1234567 ,

 

Please use 

${pageProperties.propertyName @ context='html'}

 

And for any parent level property 

${inheritedPageProperties.propertyName}

 

And if you want to fetch component's property from page(components html) then make use of model of that component in page. There is no direct way to fetch those

 

If you need those properties in same component's html then simply use ${properties.propertyName}

 

Hope this helps!!!

 

Thanks

4 replies

Umesh_Thakur
Community Advisor
Community Advisor
Aug 6, 2021 4:50 AM UTC

Simply use ${pageProperties.name_of_the_property@ context='html'} or ${pageProperties.name_of_the_property}

for example to get title of the page use ${pageProperties.jcr:title @ context='html'} or ${pageProperties.jcr:title}

 

this is to get only currrent page properties if you need parent page properties you can use inheritedPageProperties to get the same.

 

Hope this will help.

Umesh Thakur

Translate
BimmiSoAdobe EmployeeAccepted solution
Adobe Employee
Aug 6, 2021 5:17 AM UTC

Hi @test1234567 ,

 

Please use 

${pageProperties.propertyName @ context='html'}

 

And for any parent level property 

${inheritedPageProperties.propertyName}

 

And if you want to fetch component's property from page(components html) then make use of model of that component in page. There is no direct way to fetch those

 

If you need those properties in same component's html then simply use ${properties.propertyName}

 

Hope this helps!!!

 

Thanks

Translate
Umesh_Thakur
Community Advisor
Community Advisor
Aug 6, 2021 11:48 AM UTC

@bimmiso 

Translate
Adalbero
New Member
Feb 26, 2025 1:54 PM UTC
Add this method to your model class then you can use:
 
${<model>.childProperties.<child-node>.<property>}
 

 

/** * Get the properties of child nodes. * * return ValueMap of the child nodes. */ @9944223 public ValueMap getChildProperties() { Resource resource = request.getResource(); Map<String, Object> map = new HashMap<>(); resource.getChildren().forEach(child -> { map.put(child.getName(), child.getValueMap()); }); return new ValueMapDecorator(map); }

 

Translate