Add breadcrumbs to a page with a user macro

SanaS
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.
November 5, 2013

I'm trying to make a simple user macro where I can display the breadcrumbs of a page anywhere on that page. Can someone help me with this one?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
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.
November 5, 2013

This should help you get started:

#set($globalHelper = $action.getHelper())

$globalHelper.getBreadcrumbs()

That gets a Java ArrayList of PageBreadcrumb objects. Here's the API for the PageBreadcrumb class:

https://docs.atlassian.com/atlassian-confluence/latest/com/atlassian/confluence/util/breadcrumbs/PageBreadcrumb.html

hth,

matt


0 votes
Chris sammut
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 6, 2016
0 votes
SanaS
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.
November 6, 2013

Bake more bread :)

It's for a customer who wants templates with some information about the page (breadcrumbs, no. of attachments etc) in a "header". They will also export these pages to pdf.

Tom Birch Hansen
Contributor
March 11, 2014

Any chance, you could share your final user macro here?

SanaS
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.
March 12, 2014
## @noparams
## MACRO: bcrumbs
## Updated: 2011-03-15
## Breadcrumbzz
## USAGE: {bcrumbs}
#set($globalHelper = $action.getHelper())
#set($breezys = $globalHelper.getBreadcrumbs())
#set ($counter = 0)
## iterate over each breadcrumb
#foreach( $breadcrumb in $breezys)
#set ($displayTitle = $breadcrumb.getDisplayTitle())
#if ($counter == 0) #else $displayTitle > #end
## increment the counter
#set($counter = $counter + 1)
#end ## end foreach
Tom Birch Hansen
Contributor
March 12, 2014

Thanks for sharing!

Matt Hutchinson August 11, 2016

Sorry to draw up an old thread, how would you expand this to make the breadcrumbs clickable / links?

0 votes
SanaS
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.
November 6, 2013

Thanks a million!

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.
November 6, 2013

Sure thing. Just out of curiousity, what are you going to do with the breadcrumbs?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events