Search code examples
adobeaemsightlyhtl

Set currentPage using dialog property in Adobe AEM


I am creating a menu component. Mouting a tree with the pages and its children.

<ul class="topnav" data-sly-list.child="${currentPage.listChildren}">

It's working fine, but I need to replace the currentPage using a property of my dialog component.

How can I do this?

I already have the dialog component and I'm able to retrieve the property value.

enter image description here

I don't wanna use java classes, I am assuming that there's a way to do this using only htl


Solution

  • There is no shorthand for getting a Page specified by a path, mostly because HTL sits lower than the WCM layer in AEM.

    You can find an example of how to do this using the Use-API (JS, but it's similar in Java) at https://github.com/Adobe-Marketing-Cloud/aem-htl-repl/blob/master/content-pkg/jcr_root/apps/repl/components/repl/template.html and https://github.com/Adobe-Marketing-Cloud/aem-htl-repl/blob/master/content-pkg/jcr_root/apps/repl/components/repl/logic.js