Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to show recent updated contents with its labels?

akiko_pusu
Contributor
December 25, 2014

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

1 vote
Answer accepted
Alex Medved _ConfiForms_
Community Champion
December 25, 2014

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.

 

akiko_pusu
Contributor
December 29, 2014

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.)

Alex Medved _ConfiForms_
Community Champion
December 29, 2014

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
TAGS
AUG Leaders

Atlassian Community Events