Macro to read previous and next page in page

MarkC
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.
September 19, 2013

I found this macro (https://confluence.atlassian.com/display/DISC/Next+and+Previous+Links) created by Matthew Horn, but it doesn't quite do everything I was hoping.

Has anyone created a macro (or modified the one above) to pull in the previous and next pages' titles?

What I want to do is to include this at the bottom of a page with the previous page's title on the left and the next page's title on the right.

I've tried fixing up the macro myself, but I've had limited success.

3 answers

1 accepted

2 votes
Answer accepted
MarkC
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.
September 22, 2013

This doesn't exactly solve my problem, but I'll post a link to the comments made by Chris Kent at the bottom of this page: https://confluence.atlassian.com/display/DISC/Next+and+Previous+Links.

I solved the issue by creating doing his suggestion, but instead of having a blank next or previous link, I redirected it to the space home page:

#if ($prev != 0)
		<div class="prev_page"><strong>Previous:</strong> <a href="$prev.getUrlPath()">$prev.getDisplayTitle()</a></div>
	#else
		<div class="prev_page"><strong>Return to </strong> <a href="$space.getUrlPath()">$space.getDisplayTitle()</a> <strong>Home</strong></div>
	#end
	#if ($next != 0)
		<div class="next_page"><strong>Next:</strong> <a href="$next.getUrlPath()">$next.getDisplayTitle()</a></div>
	#else
		<div class="next_page"><strong>Return to </strong> <a href="$space.getUrlPath()">$space.getDisplayTitle()</a> <strong>Home</strong></div>
	#end

Matthew J. Horn
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.
September 22, 2013

This is great, thanks for posting your solution!

David Hergert _PAYX_ September 2, 2014

How does anyone comment on those pages?

Thomas Kreft December 23, 2015

I can't seem to get this solution to work in Confluence 5.9.1. I added this macro to the top of a couple of "adjacent" pages (according to the page hierarchy view), like this: * Parent Page * Child Page 1 ("First Page" set) * Child Page 2 * Child Page 3 ("Last Page" set) All that gets rendered is the text "Return to <Parent Page> Home", twice. Did I make an error implementing/using this user macro or did Confluence 5.9.1 break something?

0 votes
MarkC
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.
September 19, 2013

UPDATE Again...

I simply created some divs to separate the content, and that solved that problem.

Does anyone know how to setup the above macro so that it only looks at pages under a specified page? For example, say you have the following page setup:

  • ROOT
    • A
    • B
      • 1
      • 2
      • 3
    • C

I want the macro to look at page B as the ROOT. Then when viewing page 1, the macro would show the previous page as B and the next page as 2. Then on page 3, it would show the previous page as 2 and the next page as B.

Nilesh Raut September 12, 2018

I want the same setup for the macro

ROOT

  • A
  • B
    • 1
    • 2
    • 3
  • C

If any have, help me with this.

Thanks in advance.

0 votes
MarkC
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.
September 19, 2013

UPDATE

I have managed to change the links from images to the page titles, but I can't seem to figure out why they always display as right-aligned on the page.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events