1

I'm doing a language picker, that permit to change between english and french, the application is on Jahia.

I would like to get the [j:fullpath] from the page I'm on from the jsp of my component languagePicker, but I don't find a way to get it. I need the j:fullpath of the current page, current page is actually ..../home/html, but $(currentNode.path) answers me :

/modules/template/02.02.01.10-SNAPSHOT/templates/base/navbar2/navbarlinks-lang

But I would like something like : " /sites/services/home", it is my actual j:fullpath for my homepage. Under this node, there's a "VanityUrlMapping" and under again 2 nodes, one for each language.

There's a vanityUrlmapping under each pages, so how to get the j:fullpath of these pages in a JSP ?

Thanks

Kalas Yagami
  • 183
  • 1
  • 20

3 Answers3

1

If your component is stored under a "normal area" (not absolute) you can go up the JCR until you find a node of type "jnt:page". This can easily be done using the following taglib: http://downloads.jahia.com/downloads/jahia/digitalfactory7.0.0/digital-factory-taglib-7.0.0.0-tlddoc/jcr/getParentOfType.fn.html

If you are trying to implement a custom language switcher for Jahia you should probably build a custom view based on the default Jahia language switching component:

https://github.com/Jahia/default/blob/master/src/main/resources/jnt_languageSwitcher/html/languageSwitcher.jsp

0

I think that ${renderContext.mainResouce.node.path} is what you are looking for.

I don't think that j:fullpath would take into account the vanity URLs. I don't do much with those, though.

peetsnack
  • 91
  • 10
0

@peetsnack is right, you must use ${renderContext.mainResource.node} to get the "mainResource" (= the containing "page" in most cases) associated to your current node (your "navbarlink" node here).

To get a correct (external) url, with vanity url, correct servername/scheme..., the simplest is to use directly this: {renderContext.mainResource.node.url}

Here is a full exemple:

   <%--Retrieve the parent page--%>
   <c:set var="parentPageUrl" value="${renderContext.mainResource.node.url}"/>
   <%-- for correct url encoding --%>
   <c:url var="parentPageUrl" value="${parentPageUrl}"/>
   <%-- if you need absolute url: --%> 
   <c:set var="parentPageUrl" value="${url.server}${parentPageUrl}"/>

REM: The following 2 pieces of code will generate the same URL:

<c:url value="${contentNode.url}" />
<c:url value="${url.base}${node.path}.html" />

source : https://academy.jahia.com/files/live/sites/academy/files/documentation/training/TR7_Basic-Developer_EN_V1.5.pdf