Couple of ways we can display current content path in presentation template
Approach 1: Create a Navigator as below and refer in presentation template
Create a Navigator Component :
Start Type: Current Content
Selected Start Area:None
Include Start: true
Ancestor Level: None
Descendant Level: None
Preceding Siblings Level: None
Next Siblings Level: None
Show Site: false
Show Content: true
Expand current navigator branch one level: false
Expand navigator to display current site area: false
Results per page:1
Start page:1
Maximum pages to include:1
Pages to read ahead:1
And add the following in design section "<Placeholder tag="sitepath"/> ..
Then include the Navigator component in the Presentation template
<Component name="Design/nav_content_path"/>
Approach 2:
Another way is create JSP component and code inside the JSP will like below
RenderingContext renderingContext = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
if ( renderingContext != null ){
request.setAttribute("sitePath",renderingContext.getPath());
out.println( renderingContext.getPath());
}
No comments:
Post a Comment