Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Retrieving the label(s) of a particular page

Is it possible to retrieve the labels of one (1) particular page?

Say, I want to use the label(s) of a page as a value in a Page Properties key/value pair without having the editor putting that infomation in there manually (he only needs to add the label to the page).

Is this possible with standard Confluence functionality?

2 answers

1 accepted

1 vote
Answer accepted
Bill Bailey Community Leader Sep 12, 2018

Well if by "standard" Confluence functionality, you include user macros, then yes. If you are comfortable with VTL and Java methods, the two you would need would be the getPage() and getLabels() (the last returns a collection).

Thanks Bill, this answers my question... 

But I don't know how to write a user macro, so I guess there is no way of obtaining what I was asking for with my standard confluence configuration.

Bill Bailey Community Leader Sep 13, 2018

Well there are guides, and samples out there. There is also a complex sample that deals with labels here:

https://github.com/unidwell/confluence-include-child-pages-macro

And yes there is a learning curve, but user macros allow you to fill in the holes in Confluence. And when I started, I knew nothing about VTL or Java. ;-) So it will take time to create this first macro, but the time will pay dividends later.

Thanks @Bill Bailey  for this insight ; I am a bit familiar with user macros, but not enough to write a full one from scratch ... Could you elaborate a bit more about how to use the getPage() and getLabels() functions?

Bill Bailey Community Leader Jun 02, 2021

If you look at this code:

https://github.com/unidwell/confluence-include-child-pages-macro/blob/master/include_pages_macro.vm 

You will see examples.  The author first calls the needed functions:

#set( $pageManager=$containerContext.getComponent('pageManager') )

Now the methods can be accessed. So for example:

#set( $currentPage = $pageManager.getPage($content.id) )

Then you can do something like this

#set( $labels = currentPage.getLables( ))

 

Spend some time breaking down how the autor constructed the macro will help a lot in learning these tricks.

Like Nicolas Casel likes this

Johan,

If you create a template and give it a label, any pages that are created using the template will automatically be created with that label.

Blue Prints and User created Templates

Victor

Hi Victor,

thanks for the response, however, that is not the answer i'm seeking..

In fact, I want to know if it is possible, using standard Confluence functionality, to retrieve the label on a page automatically in a Page Properties field on that same page, so that i can report that label in the table that is automatically generated by a Page Properties Report macro.

I want to avoid that people need to add the label and secondly, the same label information in a properties field.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Confluence

Miss the Confluence demos at Team 21? Watch them here!

Phew, Atlassian Team 2021 blew by. With dozens of demos and a handful of keynotes, you may have missed some of the awesome Confluence Cloud sessions. Don't' worry, you can watch them all here or on Y...

201 views 2 5
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you