Add link to navigate to parent page

Brian Jones January 9, 2013

Is there a (easy) way to add a link to the current parent page that will continue to work after pages are rearranged in the hierarchy? I'm not sure we will be able to install a plugin. If we do install a plugin, it has to be rock solid.

Example: (Read ~ as whitespace)

A (parent of B)
|
+-- B (parent of CD)
~~~|
~~~+-- C (Child of B)
~~~+-- D (Child of B)

B has a link that navigates to A

CD have links that navigate to B

Then change happens, and the tree is re-organized to look like this:

A (parent of D)
|
+-- D (parent of BC)
~~~|
~~~+-- B (Child of D)
~~~+-- C (Child of D)

Now, without having to edit the pages...

BC's link navigate to D

D's link navigates to A

5 answers

1 accepted

0 votes
Answer accepted
Daniel Borcherding
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 10, 2013

Hello Brian,

You can use the Documentation theme to embed a page three macro on the left hand side of each page.

https://confluence.atlassian.com/display/DOC/Configuring+the+Documentation+Theme

This will give you a full page tree rendered on each of the pages of a space. It will include links to all descendants from the root of the space much in the matter you outline above.

Please let us know if that works for you.

Brian Jones January 13, 2013

I had forgotten about the docuemntation theme. While the space I'm using has the documentation theme on, it is too cluttered making it awkward to navigate. I may end up moving my pages to a new space since they are designed as a documentation collection.

Daniel Borcherding
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 15, 2013

Brain,

Pushing this idea a bit furhter I created the following feature request.

https://jira.atlassian.com/browse/CONF-27737

Supporting links to @<locations> may be a way to get the functionality you are looking for without the extra bulk of the documentation theme. If you think it is a good idea please give it a vote up in the upper right hand corner.

6 votes
Stephen Deutsch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 24, 2013

I was using the solution provided by Richard for a while, but unfortunately the page information tools hasn't been updated for the newest version of Confluence (not to mention that Confluence tries to update any wiki markup whenever it gets a chance).

After searching a bit, I finally found that you can make a simple user macro that will provide the same functionality.

## @noparams
#contentLink2($content.getParent() false false)

Add a user macro, choose a name and title (I used linktoparent and "Link to Parent") and leave the rest of the options at the default values. Copy and paste these two lines into the macro body field and save, and it should work.

David Grierson September 14, 2014

This works really well but is only 99% complete. I've updated this with the following code instead: ## @noparams #if (!$content.getParent()) <b>No parent page found</b> #else #contentLink2($content.getParent() false false) #end

Like # people like this
Evgeny Victorov August 3, 2015

@David Grierson thanks a lot, you've just saved an hour of research for a single person, thousand hours for thousands of seekers!

Like Tomáš Vrabec likes this
Jim West May 16, 2017

@David Grierson. I concur, thank you for this. Exactly what I was looking for. 

4 votes
Ronald Horner March 4, 2013

Here is our solution. I will always display the name of the parent page and make it clickable. It will dynamically change no matter where you move the page to updating the parent link appropriately.

You'll need these macros:

  1. Click Edit on the page you wish to add the link
  2. Click Insert -> Wiki Markup
  3. Insert some dummy wiki tags like {bogus}{bogus}
  4. Click Insert
  5. In the Wiki Markup panel remove the bogus tags
  6. Insert the following wiki markup
{link-to:@parent}
{page-info:title|page=@parent}
{link-to}

0 votes
vincent_marx_external November 19, 2020

Hi,

If it can be useful:

## @param Title:title=Title|type=string|required=true|default=Go Back
## @param Style:title=Style|type=enum|required=true|enumValues=Primary,Standard|default=Primary

#set($btnClass="")
#set($txtColor="")
#if($paramStyle == "Primary")
#set($btnClass="aui-button-primary")
#set($txtColor="color:white")
#end

#if (!$content.getParent())
<b>No parent page found</b>
#else
<span>
<a class="aui-button aui-button-compact $btnClass"
style="position: absolute"
title="$content.getParent().getTitle()"
href="/pages/viewpage.action?pageId=$content.getParent().getId()"
>
<span class="aui-icon aui-icon-small aui-icon-small aui-iconfont-chevron-left-circle"></span>
<span style="$txtColor">$paramTitle</span>
</a>
</span>
#end

Preview:

go-back.png

Have a nice day,
-- Vincent

0 votes
CharlesH
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 11, 2013

The Reporting plugin would be one option here. It brings an "awareness" to the situation, so for instance, you could define a link on the current page which points at the parent page. This is not hard coded though, so if the page moves, then the link will point to the new parent.

{report-link:content:parent &gt; content:url|default=_This page has no parent._}View parent page{report-link}

More info here: http://wiki.customware.net/repository/display/REPORT/report-link

I can recommend this plugin. It is a commercial one, but the license cost is reasonable in my view.

An alternative approach could be to write a user macro, as I think the Confluence objects available in Velocity (user macro language) will allow you to identify the parent of the current page, and so create suitable links.

Brian Jones January 13, 2013

Charles--thanks for the pointer. I like the capability of the reporting plugin. I wish we had it!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events