I would like to display the pages under which the current page is nested in a breadcrumbs format along with the link.
This article was helpful to get the output but I would also need each of the pages in the breadcrumbs to have links.
Any suggestions?
Thanks in advance!
FYI, this is for Confluence Data Center version.
Hello @Lavesh Budhrani ~ if this is for DC, you could create a user macro (as opposed to a paid Marketplace app). User macros aren't available in Cloud. Here's an old post that may help (I haven't tested this): https://community.atlassian.com/t5/Answers-Developer-Questions/Add-breadcrumbs-to-a-page-with-a-user-macro/qaq-p/507751
I was able to use the following user macro code that displays the breadcrumbs in such a format:
Page Level 1 / Page Level 2 / Page Level 3 / Current Page
## @noparams #set($breadcrumbs = "") #set($breadcrumbSeperator = " / ") #getBreadcrumbs($content.id) $breadcrumbs ##recursive macro to get the path to page breadcrumbs #macro( getBreadcrumbs $contentID ) #set($thePage = $pageManager.getPage($contentID)) #set($breadcrumbs = $thePage.getTitle() + $breadcrumbs) ## Does this iteration have a parent? #if($thePage.getParent()) #set($breadcrumbs = $breadcrumbSeperator + $breadcrumbs) ## Get parent of this iteration #getBreadcrumbs($thePage.getParent().getContentId().asLong()) #end #end
I would like to enhance this code to make the breadcrumbs clickable. Any help on this is greatly appreciated!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Expanding upon Previous post to add in clickable links and dynamic toggle for long breadcrumb path. Added in Styling and JQuery to help with view and toggle functionality
## Macro Name: breadcrumbles
## Macro Title: BreadCrumbles
## Description: Creates Breadcrumb for current page
## Category: Administration
## Macro Body Processing: No Macro Body
##Template: ----begin code
## @noparams
#set($breadcrumbsAsHtml ='')
#set($currentPageID = $content.id)
#getBreadcrumbs($content.id)
<div class='BreadCrumbles'>$breadcrumbsAsHtml</div>
##recursive macro to get the path to page breadcrumbs
#macro( getBreadcrumbs $contentID )
#set($thePage = $pageManager.getPage($contentID))
## ID comparison catch to avoid clickable link for current page and add in toggle element
#if($contentID == $currentPageID)
#set($breadcrumbsAsHtml = "<span class='BCtoggle' title='Click to View Full Breadcrumb Path'>...</span><span style='bold'>" + $thePage.getTitle() + "</span>" + $breadcrumbsAsHtml )
#else
## Create clickable link for all Parent pages
#set($breadcrumbsAsHtml = "<a href='"+$thePage.getUrlPath()+"'>" + $thePage.getTitle()+ "</a>" + $breadcrumbsAsHtml )
#end
## Does this iteration have a parent?
#if($thePage.getParent())
#set($breadcrumbsAsHtml = $breadcrumbsAsHtml)
## Get parent of this iteration
#getBreadcrumbs($thePage.getParent().getContentId().asLong())
#end
#end
<style>
.BreadCrumbles a:not(:first-child) {display:none;}
.BreadCrumbles a {position:relative}
.BreadCrumbles a:after {
content:' \\ ';
}
.BreadCrumbles .BCtoggle {
font-size: 22px;
font-weight: bold;
line-height: 6px;
padding: 0px 4px;
background: #fff;
display: inline-block;
vertical-align: middle;
height: 18px;
border-radius: 6px;
margin: 0 6px;
border: 2px solid #ccc;
cursor:pointer;
transition:all .3s ease-in-out;
}
.BreadCrumbles .BCtoggle:hover{
background:#e0e0e0;
}
.BreadCrumbles .BCtoggle.closeBC {
line-height: 16px;
font-family: monospace;
}
</style>
<script>
AJS.toInit(function(){
AJS.$('.BreadCrumbles .BCtoggle').click(function(){
AJS.$('.BreadCrumbles a:not(:first-child)').toggle();
AJS.$(this).text(AJS.$(this).text() == '...' ? ' < ' : '...');
AJS.$(this).toggleClass('closeBC');
});
});
</script>
##Template: ----End code
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Today only! Share what you’re the most excited about for Team ‘25 or just dance out the beginning of a new quarter with us.
Comment the postOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.