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

template.getName() not working on publish env

Avatar

Level 4

Hi All,

I want to output template name as a css class on body tag of my page. In body.jsp we have done this, which works on author env but does not work on publish env? Is it because template resource is not available in publish env. Is there a simple way to fix it?

<c:set var="pageCssClass" value="${currentPage.name}-page" /> <c:set var="templateCssClass" value="${currentPage.template.name}-template" /> <body class="<c:out value="${pageCssClass} "/><c:out value="${templateCssClass} "/><wcmmode:edit>edit</wcmmode:edit>"
1 Accepted Solution

Avatar

Correct answer by
Level 8

Oh.  Hmm, I honestly don't know how you'd do that other than splitting the string.

View solution in original post

4 Replies

Avatar

Level 8

The template itself cannot be read on Publish because of read permissions under the /apps folder.

You can switch your code to use ${currentPage.properties['cq:template']}

Avatar

Level 4

Yes that give me long path like 

      
cq:template
String
/apps/mysite/templates/default-page

 Even though I can get the last element after last "/". But wanted to know if there is better way.

Avatar

Correct answer by
Level 8

Oh.  Hmm, I honestly don't know how you'd do that other than splitting the string.

Avatar

Level 4

Thanks for your reply, I can't thinking anything else will go with the string split option