Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

HTL currentPage.listChildren component

Avatar

Level 2

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

1 Accepted Solution

Avatar

Correct answer by
Level 5

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 !

View solution in original post

4 Replies

Avatar

Correct answer by
Level 5

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 !

Avatar

Level 2

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

Avatar

Level 5

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

Avatar

Level 2

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