1. Home
  2. Docs
  3. Confluence
  4. Confluence User Macros
  5. Add Parent ID as Label

Add Parent ID as Label

Summary

This Confluence user macro adds the parent content ID (page ID) as a label to the current page.

Use Case

On several occcasions I received the requirement to add the parent page ID as a label to the (current) child page. This was helpful for certain plugins or simply needed as a relational link to the parent’s page topic.

Source Code

#* ============================================================================
 * ADD PARENT ID AS LABEL
 *
 * This Confluence user macro adds the parent content ID (page ID) as a label 
 * to the current page.
 *
 * Version: 1.0.002
 * Date:    2016-11-17
 * Author:  George Lewe
 * Source:  https://github.com/glewe/add-parent-id-as-label
 * License: GNU LGPLv3
 *
 * Macro body:      None
 * Body processing: None
 *#

#* ----------------------------------------------------------------------------
 * PARAMETERS
 *#
## @noparams

#* ----------------------------------------------------------------------------
 * INPUT
 *#

#* ----------------------------------------------------------------------------
 * OUTPUT
 *#
#set($myLabel = ""+$content.parent.id)
#set($success = ${content.labelUtil.addLabel($myLabel,$action.labelManager,$content)})

 

Was this article helpful to you? Yes No

Leave a Reply

Your email address will not be published. Required fields are marked *