Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 21:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi
I would like to list only child pages with a specific label in my Confluence page.
I can't see that this is possible with children-display.
Does anyone have a solution?
Regards,
Michael Danielsson
Here's a user macro that does it (I varied from my suggested approach slightly):
## Macro title: Label Search ## Macro has a body: N ## Body processing: n/a ## Output: HTML ## ## Developed by: Matthew J. Horn ## Date created: 10/24/2013 ## Installed by: Matthew J. Horn ## @noparams ## Define variables: #set ($labelList = []) ## #set ($pageMatches = []) #set ($counter = 0) #set ($labelToMatch = "comments") <strong>Search for "$labelToMatch" Label</strong><br/> #macro( process $rp ) #set( $pagelist = $rp.getSortedChildren() ) #foreach( $child in $pagelist ) ## child is of type Page #set( $labelList = $child.getLabels() ) #foreach ($label in $labelList) #if ($label == $labelToMatch) <br/>$child.getTitle() has the "$labelToMatch" label on it #end #end #set( $counter = $counter + 1 ) ## make this #if( $child.hasChildren() ) #process( $child ) #end #end #end
## Check to see if the page is the home page of the space.
## Otherwise, get to the home page.
#if ($content.isRootLevel() == "false")
#set($spaceHome = $space.getHomePage()) #process($spaceHome) #else #process($content) #end <br/><br/><strong>$counter pages checked.</strong>
How do I get this macro to start with the current page and just check its children?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should be able to do this with a user macro. On the parent page, get a List of child pages with the getDescendants() method. Then iterate over them and for each page call getLabels(). Check for the label you want, and build a list of the pages that match.
You can basically do all this with the Page class:
https://docs.atlassian.com/atlassian-confluence/latest/com/atlassian/confluence/pages/Page.html
hth,
matt
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I want to do it without any java coding.
Is that possible?
Regards,
Michael Danielsson
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Writing user macros is not at all like Java coding. It uses Java syntax, but you don't do any compilation. Confluence takes care of that for you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The page properties report can do this, but it will report the child pages' properties rather than a standard page listing. However, it does allow you to filter by label, and in "Add filter" you can limit it to direct children or to descendants of the current page.
That may work for some people who stumble across this question.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You could use the reporting plugin and do something like this:
{report-table}
{local-reporter:page:children|source=Page Name}
{content-filter:label=label name}
{local-reporter}
{report-column:title=Column Title}
{report-info:page:title}
{report-column}
{report-table}
Regards,
Kay
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.