Hello,
I'm trying to link to a space's home page from within a decorator template.
Here is an excerpt from atlassian-plugin.xml
<!-- ITDP News page https://developer.atlassian.com/display/CONFDEV/Decorator+Module --> <decorator key="news" name="News Decorator" page="itdp/news.vmd"> <description>ITDP News Page Decorator</description> <pattern>/display/vc/News</pattern> </decorator> <!-- Override Main Decorator --> <layout key="main" name="Main Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/main.vmd"> <resource type="velocity" name="decorator" location="itdp/main.vmd" /> </layout> <!-- Override Page Decorator --> <layout key="page" name="Page Decorator" class="com.atlassian.confluence.themes.VelocityDecorator" overrides="/decorators/page.vmd"> <resource type="velocity" name="decorator" location="itdp/page.vmd" /> </layout>
These templates include another template like so:
#parse ("/itdp/includes/logo.vmd")
Logo.vmd contains the following
<div id="logo"> <h1><a href="$req.contextPath/display/$space.Key/">ITDP</a></h1> </div><!-- /#logo -->
I've tried using $space.Key and $space.getHomePage().getUrlPath(), but neither render.
I'm trying to understand what I'm doing incorrectly.
Thanks!
-Shawn
Community moderators have prevented the ability to post new answers.
Instead of substituting the space key directly into an URL, try using the getUrlPath function instead:
#set ($myUrl = $req.contextPath + $space.urlPath) <a href="$myUrl">HOME<a>
In addition to your example (which will work for most spaces), this approach will also work for personal spaces, and spaces that have reserved URL characters in the space key.
I was able to get this working in my scenario using the following code:
<div id="logo"> <h1><a href="$req.contextPath/display/$spaceKey/">HOME</a></h1> </div><!-- /#logo -->
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.