Skip to content

Instantly share code, notes, and snippets.

@codec
Last active December 22, 2015 15:49
Show Gist options
  • Save codec/6494771 to your computer and use it in GitHub Desktop.
Save codec/6494771 to your computer and use it in GitHub Desktop.
Create a table including child pages and likes.
## @noparams
## wtf, seriously!?
#set($containerManagerClass = $action.class.forName('com.atlassian.spring.container.ContainerManager'))
#set($getInstanceMethod = $containerManagerClass.getDeclaredMethod('getInstance',null))
#set($containerManager = $getInstanceMethod.invoke(null,null))
#set($containerContext = $containerManager.containerContext)
## now what we actually need ...
#set($likeManager = $containerContext.getComponent('likeManager'))
#set($childpages = $content.getChildren())
<table class="aui aui-table-sortable">
<thead>
<tr>
<th class="aui-table-column-unsortable">Session</th>
<th>Likes</th>
</tr>
</thead>
<tbody>
#foreach($childpage in $childpages)
#set($macro = "{excerpt-include:${content.spaceKey}:${childpage.getTitle()}|nopanel=true}")
<tr>
<td>
<h3><a href="$generalUtil.getPageUrl($childpage)">$childpage.getTitle()</a></h3>
<p>
${action.getHelper().renderConfluenceMacro($macro)}
</p>
</td>
<td>$likeManager.getLikes($childpage).size()</td>
</tr>
#end
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment