Created
April 25, 2013 01:41
-
-
Save keithws/5456904 to your computer and use it in GitHub Desktop.
FreeMarker template code to create a list of users sorted by their last blog post publish date across many blogs or a single blog in Jive SBS. Tested on version 4.5.5.2 in the blog-macros.ftl file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<#function getBlogContributors blogs> | |
<#local contributors = [ ]> | |
<#local contributorsWithDate = [ ]> | |
<#local blogPostObjectType = 38> | |
<#local resultFilter = action.getResultFilter()> | |
<#if blogs?has_content> | |
<#list blogs as blog> | |
<#list blog.contributors as contributor> | |
<#if (!(contributors?seq_contains(contributor)))> | |
<#-- check if user is blocked --> | |
<#if (! (contributor.properties.containsKey("visible.blog.contributor") && (contributor.properties.get("visible.blog.contributor") == "false")))> | |
<#-- add property with last blog post publish date --> | |
<#local lastBlogPostPublishDate = contributor.creationDate> | |
<#-- repurpose the result filter --> | |
${resultFilter.setUserID(contributor.getID())} | |
${resultFilter.setNumResults(1)} | |
${resultFilter.setSortPropertyName("PublishDate")} | |
<#-- limit search if there is only one blog in list --> | |
<#if blogs?size lte 1> | |
${resultFilter.setBlogID(blog.ID)} | |
</#if> | |
<#local lastBlogPosts = jiveContext.blogManager.getBlogPosts(resultFilter)> | |
<#if lastBlogPosts?? && lastBlogPosts.hasNext()> | |
<#list lastBlogPosts as lastBlogPost> | |
<#local lastBlogPostPublishDate = lastBlogPost.publishDate> | |
</#list> | |
</#if> | |
<#local contributors = contributors + [ contributor ]> | |
<#local contributorsWithDate = contributorsWithDate + [ {"user": contributor, "lastBlogPostPublishDate": lastBlogPostPublishDate } ]> | |
</#if> | |
</#if> | |
</#list> | |
</#list> | |
</#if> | |
<#return contributorsWithDate> | |
</#function> | |
<#if blogs??> | |
<#local contributors = getBlogContributors(blogs)> | |
<#else> | |
<#if blog??> | |
<#local contributors = getBlogContributors([blog])> | |
</#if> | |
</#if> | |
<#if contributors?? && contributors?size gt 0> | |
<ul> | |
<#list contributors?sort_by("lastBlogPostPublishDate")?reverse as contributor> | |
<li>${contributor.user.username}</li> | |
</#list> | |
</ul> | |
</#if> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment