How to show recent updated contents with its labels?

Hello.

I hope to get the recent updated contents information with their labels.

Just like this Atlassian Answers's top page.

This is because "Recent update macro" does not display labels of each pages, so it 's not easy for users to understand the content information only with its page title.

Any ideas, including plugin informations are appreciated.

1 answer

1 accepted

Hi,

Not sure if there is a macro to do that (probably is), but it is quite easy to achieve with a simple user macro (https://confluence.atlassian.com/display/DOC/Writing+User+Macros)

Something like this to start with:

## Macro title: Recent Pages
## Macro has a body: N
##
## Developed by: Vertuna llc
## Date created: 26/11/2014
## This is an example macro


## @param Space:title=Space key|type=string|required=true|desc=Space key


#set ($pages = ${pageManager.getRecentlyUpdatedPages(5, $paramSpace)})
#foreach ($p in $pages)
  <h3><a href="$p.urlPath">$p.displayTitle</a></h3>
    #foreach ($l in $p.labellings)
  <a class="aui-label" href="$l.label.urlPath">$l.label.name</a>
    #end
#end

There is a limit of 5 set to getRecentlyUpdatedPages method, you can change it to anything you like, or make it parametrisable if needed.

 

Hi, Sash, thanks for the answer and taking your time! Since I want to get the recent update contents of all the spaces, then I changed the $paramSpace to 'null'. If I am allowed to ask for more, I wish "Show More" link is enabled, which allows users to see older pages/news/blogposts. Also, it seems "favorite" labels which added by current user are included in the results, I hope to exclude "favorite" labels. (Maybe this is not so difficult.)

Yes, to look for all spaces 'null' should be used as a parameter to getRecentlyUpdatedPages method, according to https://docs.atlassian.com/confluence/latest/com/atlassian/confluence/pages/PageManager.html#getRecentlyUpdatedPages(int, java.lang.String) As for "Show More" link.. it does depends on how you would need to implement it. If just a link that shows already rendered pages list then it is doable using the UserMacro with not so much effort, but if you need this to be dynamically loaded then you probably would go with a "normal" custom confluence macro and how something as rest endpoint defined to load "next" page of pages (unless there is a rest api already to do that) "favorite" labels you can just exclude by name from showing, as user "favourite" is just a label with this "constant name", see more about labels: https://docs.atlassian.com/confluence/latest/com/atlassian/confluence/labels/Labelling.html

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 11, 2018 in Confluence

What are your project planning tips?

Hello Community,  Jessica here from the Confluence product marketing team! Today I wanted to get your takes on project planning –– what works, what doesn’t, how do you know if you’re doing it r...

333 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