I'm trying to use local-reporter to count the number of children with a particular label... I must not be using the collection supplier correctly, as I'm not seeing any text output.
{report-block} {local-reporter:value:label risk_open > label:content} {content-filter:@self|scope="My Parent Page" > children} {local-reporter} {report-body}{report-info:@self > collection:size}{report-body} {report-block}
I've changed report-info to print out the titles of all associated wiki pages, and that does work... not getting a total count though.
Thoughts?
Dave
Hi Dave,
If you want the size, it's simpler using a {report-variable} instead, like so:
{report-variable:My Labeled Children}
{local-reporter:value:label risk_open > label:content}
{content-filter:@self|scope="My Parent Page" > children}
{local-reporter}
{report-variable}
{report-info:variable:My Labeled Children > collection:size}
Hope that helps!
Awesome! Thanks David... works perfectly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
To count the child pages of a page with a specific label, please use a usermacro.
## @param label:title=label|type=string|required=true|desc=The label of the childpages #set($pageCount = 0) #foreach( $child in $content.children ) #foreach( $childlabel in $child.labels ) #if($childlabel.name == $paramlabel ) #set($pageCount = $pageCount +1) #end #end #end There are $pageCount Child pages with label $paramlabel
You can call this macro with "{usermakroname:label=labeltosearchfor}". I have testet this code with my Confluence 4.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, i'm new confluence. If i want to count pages from all decendants within a pointed label. how can i update your code. In my mind , define a function with recursion to caculate all of pages from decendanta within pointed label, but tried without result. Here is my code :
## @param label:title=label|type=string|required=true|desc=The label of the childpages
#set($pageCount = 0)
#marco(getTotal $node, $pageNumber)
#foreach( $child in $node.children )
#foreach( $childlabel in $child.labels )
#if($childlabel.name == $paramlabel )
#set($pageCount = $pageCount +1)
#end
#if($child.children.size>0)
#getTotal($child,$pageNumber)
#else
#end
#end
#getTotal($content, $pageNumber)
Please help!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, the macro to count the children of the CURRENT PAGE by label works fine for me. Now I would like to count the children of a SPECIFIC PAGE by label. This specific page is being spefied as a parameter: ## @param parentpage:title=Page|type=confluence-content|required=true|desc=Select a page which children to count Then I use "$paramparentpage.children" to find the children of $parentpage: #foreach( $child in $paramparentpage.children ) But I am always getting 0 as a result for the number of child pages. Any hint very much appreciated. Here is the full macro: ## @param parentpage:title=Page|type=confluence-content|required=true|desc=Select a page which children to count ## @param label:title=label|type=string|required=true|desc=Specify a label to count #set($pageCount = 0) #foreach( $child in $paramparentpage.children ) #foreach( $childlabel in $child.labels ) #if($childlabel.name == $paramlabel ) #set($pageCount = $pageCount +1) #end #end #end $parampage $paramlabel: $pageCount
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This should work:
## @param ParentPage:title=Page|type=confluence-content|required=true|desc=Select a page for which to count the children ## @param Label:title=label|type=string|required=true|desc=Specify a label to count #set($pageCount = 0) #set ( $colonIndex = $paramParentPage.indexOf(":") ) #if ( $colonIndex == -1 ) #set ( $parentSpaceKey = $space.key ) #set ( $parentPageName = $paramParentPage ) #else #set ( $parentSpaceKey = $paramParentPage.substring(0, $colonIndex) ) #set ( $parentPageNameIndex = $colonIndex + 1 ) #set ( $parentPageName = $paramParentPage.substring($parentPageNameIndex) ) #end #set ( $parentPage = $pageManager.getPage($parentSpaceKey, $parentPageName) ) #foreach( $child in $parentPage.descendents ) #foreach( $childlabel in $child.labels ) #if($childlabel.name == $paramLabel ) #set($pageCount = $pageCount +1) #end #end #end <p>Under $parentPageName there are $pageCount pages with the label $paramLabel</p>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot, Stephen! The macro now does its job perfectly! This was a great help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm looking for a variation of this that would return the number of active pages in a space based on the spacekey passed as a parameter? I've looked at a lot of examples but nothing seems to work. I keep getting total pages (including deleted, previous versions, etc.) instead of just the number of current active pages in the space.
Any help would be greatly appreciated!
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 write a macro that counts only descandants. For this example, the result is 4. We don't have to give the parent name parameter as a "Quotes" , we can just give labels to these 4 pages. How can I do it ?
Thanks in advance
Tansu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online 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.