Jahia Template Forum > How to retrieve...

0 (0 Good)
0 (0 Bad)

How to retrieve the "page template" name in jsp file?

by  bpironet »  2014/01/17 07:39

Everything is in the title. 

My goal is to retrieve the "page template" name to use in a test to adapt html (css, specific tags) based on which kind of page is currently rendered.

By the way, if you have better idea than basing this test on page template's name, I'm interested. 

Regards,

Benoit

  • How to retrieve the "page template" name in jsp file?
    2014/01/17 07:39

    bpironet <p> Everything is in the title.&nbsp;</p> <p> My goal is to retrieve the &quot;page template&quot; name to use in a test to adapt html (css, specific tags) based on which kind of page is currently rendered.</p> <p> By the way, if you have better idea than basing this test on page template&#39;s name, I&#39;m interested.&nbsp;</p> <p> Regards,</p> <p> Benoit</p>

  • Number of messages  5
    Registration date Jan 17, 2014
    0 (0 Good)
    0 (0 Bad)

    Re : How to retrieve the "page template" name in jsp file?

    by  fabu »  2014/01/17 14:11

    Hi Benoit,

    I think what you are looking for is:

        <c:choose>
            <c:when test="${jcr:isNodeType(renderContext.mainResource.node, 'jnt:page')}">
                <c:set var="currentPage" value="${renderContext.mainResource.node}" />
            </c:when>
            <c:otherwise>
                <c:set var="currentPage" value="${jcr:getParentOfType(renderContext.mainResource.node,'jnt:page')}" />
            </c:otherwise>
        </c:choose>
        
        <%-- your wanted result --%>
        ${currentPage.properties['j:templateNode'].node.name}
    Best regards,
  • Re : How to retrieve the "page template" name in jsp file?
    2014/01/17 14:11

    fabu <p> Hi Benoit,</p> <p> I think what you are looking for is:</p> <blockquote> <div> &nbsp; &nbsp; &lt;c:choose&gt;</div> <div> &nbsp; &nbsp; &nbsp; &nbsp; &lt;c:when test=&quot;${jcr:isNodeType(renderContext.mainResource.node, &#39;jnt:page&#39;)}&quot;&gt;</div> <div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;c:set var=&quot;currentPage&quot; value=&quot;${renderContext.mainResource.node}&quot; /&gt;</div> <div> &nbsp; &nbsp; &nbsp; &nbsp; &lt;/c:when&gt;</div> <div> &nbsp; &nbsp; &nbsp; &nbsp; &lt;c:otherwise&gt;</div> <div> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;c:set var=&quot;currentPage&quot; value=&quot;${jcr:getParentOfType(renderContext.mainResource.node,&#39;jnt:page&#39;)}&quot; /&gt;</div> <div> &nbsp; &nbsp; &nbsp; &nbsp; &lt;/c:otherwise&gt;</div> <div> &nbsp; &nbsp; &lt;/c:choose&gt;</div> <div> &nbsp; &nbsp;&nbsp;</div> <div> &nbsp; &nbsp; &lt;%-- your wanted result --%&gt;</div> <div> &nbsp; &nbsp; ${currentPage.properties[&#39;j:templateNode&#39;].node.name}</div> </blockquote> <div> Best regards,</div>

  • Number of messages  28
    Registration date Jan 17, 2014
    Contact
    Share
    Feedback

    Get in touch

    Whether you are a current user or if you are just evaluating Jahia, we are here to help.

    Contact us

    Share this page