can you include all child pages automatically?

This question is in reference to Atlassian Documentation: Include Page Macro

Is it possible to use this or another macro to automatically include the content of all child pages in the parent automatically?

4 answers

This widget could not be displayed.

There is a commercial add-on (projectdoc - biased alert! I'm one of the authors  smile) that allows to transclude fragments of a document query result set. In the documentation there is an example on how to transclude child documents. The macro takes care of heading level adjustments and allows to filter on the transcluded sections.

The downside is that you need to define sections in the child documents (or any document you want to transclude), since only content of sections is transcluded. This is very similar to the Excerpt Macro provided by Atlassian.

This widget could not be displayed.

Hi Nate,

You can use the Children Display macro.  It is located in the macro browser.

 

Regards,

Kay

I believe they want the content of the pages. Not just the links to the pages.

This widget could not be displayed.

Here is a user macro that I wrote for this a while back.

 

Macro Name:
include_children

Macro Title:
Include Children 

Macro Body Processing:
No macro body

Template:

## Macro Name: include_children
## Visibility: 
## Macro Title: Include Children
## Description: This will include the content from from the child pages onto the parent page that this macro is placed on.
## Categories: Confluence content
## Icon URL: 
## Documentation URL: https://bitbucket.org/fredclown/confluence-user-macros
## Macro Body Processing: No macro body

##############################
##       Template:          ##
##############################
## Developed By: Davin Studer
## Date Created: 12/4/2014
## Updated by: Milo Grika
## Added: show/hide title, link/unlink title.
## Updated by: Gregor Mirai
## Date updated: 26/1/2016
## Added: page separator, PDF split page marker options.
 
## @param ShowTitle:title=Show Title|type=boolean|desc=Deselect to remove the title of the child page.|default=true
## @param LinkTitle:title=Link Title|type=boolean|desc=Select to turn the titles of the child pages into links to those pages (Show Title must be selected).|default=false
## @param PageSeparator:title=Page Separator|type=boolean|desc=Separate pages with horizontal ruler.|default=false
## @param SplitPages:title=Split Pages|type=boolean|desc=Split pages marker for PDF export will be inserted.|default=false
## @param Collapsible:title=Collapsible|type=boolean|desc=Should the included pages be collapsible?|default=false
## @param FilterLabel:title=Filter on Page Label|type=string|desc=Include only subpages with the specified label.
## @param Order:title=Order|type=enum|enumValues=Nav Order,Reverse Nav Order,Alphabetical,Reverse Alphabetical,Create Date,Reverse Create Date|default=nav order|desc=In what order should the child pages be displayed? Nav Order refers to the order of the child pages in the page tree. Reverse Nav Order simply reverses that.

#set( $containerManagerClass=$content.class.forName('com.atlassian.spring.container.ContainerManager') )
#set( $getInstanceMethod=$containerManagerClass.getDeclaredMethod('getInstance',null) )
#set( $containerManager=$getInstanceMethod.invoke(null,null) )
#set( $containerContext=$containerManager.containerContext )
#set( $pageManager=$containerContext.getComponent('pageManager') )

## Find the array of (sorted) child pages.
#set( $data = "" )
#if( $paramOrder == "Nav Order" || $paramOrder == "Reverse Nav Order" )
    #set( $children =  $pageManager.getPage($content.id).getSortedChildren() )
#elseif( $paramOrder == "Alphabetical" || $paramOrder == "Reverse Alphabetical" )
    #set( $array =  $pageManager.getPage($content.id).getChildren() )
    ###############################################################
    ## Could not find a method to get them in Alphabetical order ##
    ## Must sort them myself ... Bubble sort                     ##
    ###############################################################
    #set( $size = $array.size() )
    #foreach( $junk in $array )
        #set( $count = -1 )
        #foreach( $line in $array )
            #set( $count = $count + 1 )
            #if( $velocityCount < $size )
                #if( $line.getTitle().compareToIgnoreCase($array.get($velocityCount).getTitle()) > 0 )
                    #set( $tmp = $array.get($velocityCount) )
                    #set( $junk = $array.set($velocityCount, $line) )
                    #set( $junk = $array.set($count, $tmp) )
                #end
            #end
        #end
    #end
    #set( $children = $array )
#elseif( $paramOrder == "Create Date" || $paramOrder == "Reverse Create Date" )
    #set( $children =  $pageManager.getPage($content.id).getChildren() )
#end

## Prepare children data. 
#set( $count = -1 )
#set( $skipped = 0 )
#set( $size = $children.size() )
#foreach( $child in $children )
    ## Create the map of labels for the page.
    #set( $labelsMap = {} )
    #foreach( $label in $child.getLabels() )
        #set( $dummy = $labelsMap.put($label.toString(), 1) )
    #end

    ## Include all pages (when no filter label is specified) or pages with a specific label.
    #if( $paramFilterLabel && !$labelsMap.containsKey($paramFilterLabel) )
        #set( $skipped = $skipped + 1)
    #else
        #set( $count = $count + 1 )
        #set( $include = "" )
        #if ( $paramCollapsible == true )
			#set( $include = $include + '<ac:structured-macro ac:name="expand">' )
			#set( $include = $include + '<ac:parameter ac:name="title">' + $child.getTitle() + '</ac:parameter>' )
			#set( $include = $include + '<ac:rich-text-body>' )
			#set( $include = $include + '<p>' )
		#end
		#set( $include = $include + '<div class="included-child-page">' )

		## Show title and links.
		#if( $paramShowTitle == true )
			#if( $paramLinkTitle == true )
				#set( $include = $include + '<h1 class="included-child-page-title"><a href="' + $child.getUrlPath() + '">' + $child.getTitle() + '</a></h1>' )
			#else
				#set( $include = $include + '<h1 class="included-child-page-title">' + $child.getTitle() + '</h1>' )
			#end
		#end

		## Include sub page.
		#set( $include = $include + '<div class="included-child-page-body">' )
			#set( $include = $include + '<ac:structured-macro ac:name="include">' )
				#set( $include = $include + '<ac:parameter ac:name="">' )
					#set( $include = $include + '<ac:link>' )
						#set( $include = $include + '<ri:page ri:content-title="' + $child.getTitle() + '" ri:space-key="' + $content.spaceKey + '"/>' )
					#set( $include = $include + '</ac:link>' )
				#set( $include = $include + '</ac:parameter>' )
			#set( $include = $include + '</ac:structured-macro>' )
		#set( $include = $include + '</div>' )
		#set( $include = $include + '</div>' )
        #if ( $paramCollapsible == true )
			#set( $include = $include + '</p>' )
			#set( $include = $include + '</ac:rich-text-body>' )
			#set( $include = $include + '</ac:structured-macro>' )
		#end

        ## Define sorting order.
        #set( $inOrder = false )
        #if( $paramOrder == "Nav Order" || $paramOrder == "Alphabetical" || $paramOrder == "Create Date" )
            #set( $inOrder = true )
        #end

        ## Find out, whether we are in between pages or not.
        #set( $betweenPages = false )
        #if( $inOrder == true && $count < $size - $skipped - 1 )
            #set( $betweenPages = true )
        #elseif( $inOrder == false && $count > 0 && $count < $size - $skipped )
            #set( $betweenPages = true )
        #end

        ## Include page separator or include page split marker used for PDF exports.
        #if( $betweenPages == true )
            #if( $paramPageSeparator == true )
                #set( $include = $include + '<hr/><br/>' )
            #end
            #if( $paramSplitPages == true )
                #set( $include = $include + '<div style="page-break-before:always;"></div>' )
            #end
        #end

        ## Add page content in order or in reverse order.
        #if( $inOrder == true )
            #set( $data = $data + $include )
        #else
            #set( $data = $include + $data)
        #end
    #end
#end
 
$data
 
<style type="text/css">
    .included-child-page {
        margin-bottom: 30px;
        overflow: hidden;
    }
</style>

 

This widget could not be displayed.

1. No, you can not.

2. There might be some free or non-free add-ons or macros, but in a corporate Jira it is an impossible mission to achieve, that sys admins would install them.

And please let me know, if a new release would bring the feature.

Davin Studer Community Champion Sep 05, 2017

The above user macro works well.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Monday in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

285 views 2 4
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you