How do I restrict child pages listed by the Children Display macro to those with a specific label?
Asked by mike.howells:

I have a bunch of parent pages where I want to list the child pages of each, but I want to have a separate list for each label.

The Children Display macro produces the output I want, but it doesn't have a parameter to specify a label. There may be a parameter that isn't shown in the dialog but I don't know how to get to the old markup syntax.


Answers:
author: heidi lund
body: It's the Reporting Plugin from Customware:

<http://wiki.customware.net/repository/display/AtlassianPlugins/Reporting+Plugin>

I've used it in this markup to produce a **bulleted list of titles of pages** that contain the specified label:

{report-list} {local-reporter:content:children\|source=PAGE TITLE} {text-sort:content:title} {content-filter:@self\|labels=+LABEL} {local-reporter} {report-body}{report-info:content:title\|link=true}{report-body} {report-list}

I've also used the following markup to produce a page that includes the **full wiki pages** (rather than just titles) of those children pages that contain the specified label(s):

{report-list} {local-reporter:content:children\|source=PAGE TITLE} {text-sort:data:Author} {content-filter:@self\|labels=+LABEL,+LABEL2} {local-reporter} {report-body}{report-info:content:body\|render=wiki}{report-body} {report-empty}_There are no reports this week._{report-empty}{report-list}

It can also be used to produce a list of children that contain **one label OR another** label - the example below will produce any children that contain LABEL1 AND either LABEL2 or LABEL3:

{report-list} {local-reporter:content:children\|source=PAGE TITLE} {text-sort:data:Author} {content-filter:@self\|labels=+LABEL1,+(LABEL2,LABEL3)} {local-reporter} {report-body}{report-info:content:body\|render=wiki}{report-body} {report-empty}_There are no reports this week._{report-empty}{report-list}

Hope that helps!


author: Matteo Gubellini _SoftComply_
body: Hi,

I am by no means a developer, but this piece of code does exactly this. You can modify it to show the links too.

```
## @param noShowLabel:title=Label|type=string|desc=Label of pages to exclude

#macro(childrenList $parentPage)
#set($childpagesSub = $parentPage.getSortedChildren())
#set($childrenN = $childpagesSub.size())
#if($childrenN > 0)
<ul>
#foreach($page in $childpagesSub)
#set($noShow=0)
#set($pageLabels = $page.getLabels())
#foreach($pageLabel in $pageLabels)
#if($pageLabel == $paramnoShowLabel)
#set($noShow=1)
#end
#end
#if($noShow==0)
<li>$page.getTitle()</li>
#childrenList($page)
#end
#end
</ul>
#end
#end

#childrenList($content)
```


author: Stefan Mueller
body: would it be possible to manipulate the result of the Children Display Macro using JaveScript in the HTML Macro?

May these sources could help to find a solution:

* [Can I create macros within an HTML macro?](https://community.atlassian.com/t5/Confluence-questions/Can-I-create-macros-within-an-HTML-macro/qaq-p/717910)
* [Jira rest api for HTML macro](https://community.atlassian.com/t5/Jira-questions/Jira-rest-api-for-HTML-macro/qaq-p/161574)
* [Restrict navmaps and content by label to pagetree](https://community.atlassian.com/t5/Confluence-questions/Restrict-navmaps-and-content-by-label-to-pagetree/qaq-p/117911)

Anyone there who can asses this and tell whether that could be done?


author: Frederick Martin
body: insert CQL Search macro with: label=\<label\> AND parent=\<parentID\>

But you get list of pages and space, no excerpt.

comments: author: Mark Stephan
body: Do you create this in User Macro? If so can you give all the details on how you did it? So we can recreate it.


author: Mike McGowan
body: I searched the Confluence JIRA project and found this Feature Enhancment -- <https://jira.atlassian.com/browse/CONF-11535> -- similar but not quite right. Does anyone know there is an Enhancement Request? I will happily vote for it.


author: Andreas
body: Ok, thanks for the reply.


author: Mike Howells
body: No, there's no easy way to filter a list of child pages by label. I've worked around it by listing all child pages with excerpts, so people can work out what they relate to without a label.


author: Andreas
body: Hi, did you find a solution? I have the same issue.


author: mike.howells
body: Those macros don't work in my Confluence. :(

What plug-in is that? What does the rendered list look like?


author: heidi lund
body: Not sure if this is exactly what you're looking for but I've used this to list a page's children pages with the label foo:

{report-list} {local-reporter:content:children} {text-sort:content:title} {content-filter:@self\|labels=+foo} {local-reporter} {report-body}{report-info:content:title\|link=true}{report-body} {report-list}

comments: author: Stefan Mueller
body: where did you use this? In the HTML Macro?


author: mike.howells
body: I tried the Checklist macro which can be restricted to child pages with a label, but the excerpt is not rendered properly (you can see HTML mark-up as plain text) and it's a table rather than a bullet list.


author: Joerg Bencke
body: Hi, I have been looking for the same. All I found ware following approaches : a) Using the page family tree plugin from adaptavist - beware, it has a performance-issue, wether it will work for you depends on the sice of the pagetreeb) Using "content by label" in combination with pagetree-unique labels ( :-( )c) (Maybe, just had the idea) Search macro with "ancestor-ID = XXXX and \<tagname\>"Let us know how you solved this. Josh

comments: author: mike.howells
body: I tried the **Advanced search** macro (had to enter as wiki input because the forms don't allow mandatory fields to be entered) but I can't get the excerpts.


Tags: child-page

label

macro