Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Linking to Space Home from a decorator

smaida September 16, 2013

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

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Joe Clark
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 7, 2013

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.

0 votes
smaida September 19, 2013

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 -->

TAGS
AUG Leaders

Atlassian Community Events