template.getName() not working on publish env | Community
Skip to main content
Level 4
February 8, 2016
Solved

template.getName() not working on publish env

  • February 8, 2016
  • 4 replies
  • 1913 views

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>"
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by leeasling

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

4 replies

Level 8
February 8, 2016

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']}

Level 4
February 8, 2016

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.

leeaslingAccepted solution
Level 8
February 8, 2016

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

Level 4
February 8, 2016

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