HTL currentPage.listChildren component | Community
Skip to main content
MavicNZ
Level 2
July 19, 2017
Solved

HTL currentPage.listChildren component

  • July 19, 2017
  • 4 replies
  • 4490 views

Hi Guys,

I have an HTL component that displays the title and description of the children of the current page, it works well but there is one thing that is bugging me.

Here's the basic code of my component. I can't get ${cover.link} or ${cover.url} to work for the href to each child page as per the instructions here. As you can see ${cover.path}.html works but it's not ideal.

<div data-sly-repeat.cover="${currentPage.listChildren}" data-sly-attribute.class="${cover.name} industry">

   <h4><a href="${cover.path}.html">${cover.title}</a></h4>

   <p>${cover.description}</p>

</div>

Any suggestions would be appreciated.

Cheers Jeff

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by zeeshanKhan0786

Hi MavicNz

Url and link are not the implicit keyword to fetch the path of your Page So when your are trying to access with the object it will not return any thing.

Check All implicit object

HTL Global Objects

Currentpage is implicit object you can fetch the methods of this api com.day.cq.wcm.api.Page

Page (Adobe AEM 6.0.0 API 6.0.0 API)

getName()  ---> name

getPath()  ---> path

getTitle()   --> title

getDescription  ---> description

Name, tilte and Path are the implicit properties in the jcr of page so it is giving you the value.

their is no such method like getLink or getUrl for this if you have these properties in your page jcr then you can fetch these properties by simply

${listChildObject.PropertyName} it will return the property if it is in jcr of page otherwise nothing will come.

Hope this will Helpful !

4 replies

zeeshanKhan0786
zeeshanKhan0786Accepted solution
Level 5
July 19, 2017

Hi MavicNz

Url and link are not the implicit keyword to fetch the path of your Page So when your are trying to access with the object it will not return any thing.

Check All implicit object

HTL Global Objects

Currentpage is implicit object you can fetch the methods of this api com.day.cq.wcm.api.Page

Page (Adobe AEM 6.0.0 API 6.0.0 API)

getName()  ---> name

getPath()  ---> path

getTitle()   --> title

getDescription  ---> description

Name, tilte and Path are the implicit properties in the jcr of page so it is giving you the value.

their is no such method like getLink or getUrl for this if you have these properties in your page jcr then you can fetch these properties by simply

${listChildObject.PropertyName} it will return the property if it is in jcr of page otherwise nothing will come.

Hope this will Helpful !

MavicNZ
MavicNZAuthor
Level 2
July 19, 2017

Hi,

Thanks for the reply, I understand that it doesn't return anything as I have tested both options.

I was probably meaning why is it detailed like that in the documentation if it's not a property you have access to?

<!--/* Good */-->

<a href="${item.link}"></a>

I was hoping that HTL might have advanced somewhat compared to the JSTL hoops you have to jump through to get a page link but it appears not.

You would think a page URL would be something fairly basic for a website CMS to make available without too much work.

Cheers Jeff

zeeshanKhan0786
Level 5
July 19, 2017

Hi Mavic,

Yes they took those example as a reference but they didn't mention the object is implicit or not.You should prefer adobe documentation in that case you find any conflict.

HTL Getting Started

Thanks

MavicNZ
MavicNZAuthor
Level 2
July 19, 2017

Thanks again,

Shows you can't always trust what you read on the internet I found what I needed on this Adobe docs page HTL Block Statements

Cheers Jeff