Adobe Global Community

Developing Clean and Efficient Lists of Items with HTL

Published on by Dan Klco on blogs.perficient.com

One of the most common patterns in AEM development is the link list. You can find this pattern in typical web elements such as navigations, headers and footers. Usually, this will be a list of links with a title and potentially some additional data such as the target or an icon. The link list is then contained within a larger component which provides the styling and wraps the link list in some containing markup. In the image below you can see some example link lists contained in red boxes.     Using JSP and the Sling TagLib, these are pretty simple to create, you’d just add something like this:   <ul> <c:foreach var="link" items="${sling:getRelativeResource('list', resource).children}"> <li> <a href="${link.valueMap.path}"> <sling:encode value="${link.valueMap.title}" mode="HTML"></sling:encode> </a> </li> </c:foreach></ul>   However, in HTL, this is somewhat more difficult. HTL doesn’t really provide the features required to traverse the AEM repository or an extension model, so you...

Tags


comments powered by Disqus