Interesting User Macros

Table of Contents

Macros

add-label-from-url

Adds a label to the current page based on the parameters passed in from the URL.

Usage: Simply append "?addLabel=labela,labelb,labelc" to the URL for the page and this macro will automatically add those labels to the current page.

Macro has a body: Macro does not have a body
Body type: Use unprocessed macro body
Macro Output: Macro generates HTML markup
Macro Body:

#set($labels = $req.getParameter('addLabel').split(','))
#foreach($label in $labels)
#set($success = ${content.labelUtil.addLabel($label,$action.labelManager,$remoteUser,$content)})
#end

Required Plugins:

include-children

Includes the contents of all of the children of the current page

Macro has a body: Macro does not have a body
Body type: Use unprocessed macro body
Macro Output: Macro generates wiki markup
Macro Body:

{report-block}
  {local-reporter:content:children} 
  {local-reporter} 
  {report-body:injected=true|render=wiki}
    {include:%title%}
  {report-body}
{report-block}

Required Plugins:

export-space

Creates a button on the current page that when clicked exports all pages in the space.

Parameters:
type (required): The output type of the export, can ONLY be XML, HTML or PDF

Macro has a body: Macro does not have a body
Body type: Use unprocessed macro body
Macro Output: Macro generates HTML markup
Macro Body:

#if($paramtype== "XML" || $paramtype== "PDF" || $paramtype== "HTML" )
    <form name="exportspaceform" method="post" action="$req.contextPath/spaces/doexportspace.action?key=$space.key">
        <input type="hidden" name="type" value="TYPE_$paramtype"/> 
        <input type="hidden" name="includeComments" value="true"/>
        #foreach ($page in $space.pages)
            <input type="hidden" name="contentToBeExported" value="$page.id"/>
        #end
        <input type="submit" name="Export Space as $paramtype" value="Export Space as $paramtype" />
    </form>
#else
    <span class="error">Error using macro: "type" is required and can only be XML, HTML or PDF</span>
#end

Required Plugins:

page-views

Generates a graph using Google's charting API representing the page views for every page in a space.

Parameters:
spaces: the space key of the space to get the pages from. (defaults to the current space)
type: the type of graph to display, "p" displays a 2d pie chart, "p3" displays a 3d pie chart. (default is "p3")
height: the height of the generated graph in pixels (defaults to 250)
width: the width of the generated graph in pixels (defaults to 100)

Macro has a body: Macro does not have a body
Body type: Use unprocessed macro body
Macro Output: Macro generates HTML markup
Macro Body:

#set($wiki = "{report-block}
{content-reporter:types=page|spaces=$!paramspaces}
{content-reporter}
{report-body:injected=true}
%page:title%,%track:view count%
{report-body}
{report-block}")
 #set($datasets = $action.helper.renderConfluenceMacro($wiki).split('\n'))
#set($values = "")
#set($labels = "")
#if($paramtype)
    #set($type = $paramtype)
#else
    #set($type = "p3")
#end
#if($paramheight)
    #set($height = $paramheight)
#else
    #set($height = 100)
#end
#if($paramwidth)
    #set($width = $paramwidth)
#else
    #set($width = 250)
#end
#foreach($dataset in $datasets)
#set($dataset = $dataset.replaceAll("<p>",  "").replaceAll("</p>",  ""))
    #set($comma = $dataset.indexOf(","))
    #if($comma > -1)
        #set($curLabel = $dataset.substring(0,$comma))
        #set($comma = $comma+1)
        #set($curValue = $dataset.substring($comma))
        #if($curValue.trim() != "0")
            #if($values != "")
               #set($values = $values + ",")
                #set($labels = $labels + "|")
            #end
            #set($labels = $labels + $curLabel.trim())
            #set($values = $values + $curValue.trim())
        #end
    #end
#end
<img class="googlechart" src="http://chart.apis.google.com/chart?cht=${type}&chd=t:${values}&chs=${width}x${height}&chl=${labels}"/>

Required Plugins:

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.