I have a macro that use to work that owed allow to select a page and a label and return the number of child pages under that page. but getting the following
Under Active Project Status Reports there are $pageCount pages with the label status-report
Instead of the number being returned I get the variable $pageCount
not sure why the this happening - any help appreciated
## @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>
If I understand your comment, you are only seeing the variable name being displayed. That would suggest that the following statement is never found to be true:
#if($childlabel.name == $paramLabel )
I would suggest using a different method to get a list of child pages, so instead of:
#foreach( $child in $parentPage.descendents )
I would try:
#foreach( $child in $parentPage.getChildren() )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.