March 15, 2020
Estimated Post Reading Time ~

HTL Basic Examples

Global Objects
·                page 
·                currentPage
·                properties
·                inheritedPageProperties
·                currentDesign
·                currentSession
·                wcmmode

Converting JSP Method into HTL

·                JSP : currentPage.getContentResource()).getResourceType()
Remove() from JSP methods
·                HTL 1 :  ${currentPage.getContentResource.getResourceType}
OR Simply Remove get from method name
·                HTL2 : ${currentPage.contentResource.resourceType}


HTL Examples

Get title of page using HTL
·                ${page.title}
Get any custom property from page using HTL
·                ${page.getProperties['root/responsivegrid/content/customPropertyName']
Handling Property Array using HTL
<div data-sly-list = "${currentPage.getProperties['component/reference']}"> 
${item}
</div>

( reference is property name , component is component node under jcr:content)



Get date using HTL
·                ${ 'dd-MMMM-yyyy hh:mm:ss' @
           format=currentPage.lastModified,

           timezone='IST',

           locale='en'}



Get logged in user using HTL

·                 ${currentSession.userID} 
Get design path using HTL
·                ${currentDesign.path}
Check wcmmode using HTL
·                ${wcmmode.edit}



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.