Using the blog-posts macro, is it possible to define a different set of labels based on user group?

I have our Confluence instance setup so that when a user logs in, there's a panel that displays the latest blog updates using the blog-posts macro. What I'd like to do is define a different label for several different user groups so that a user in one group sees different updates from a user in another.

I know that the page-include macro will respect the "groups" parameter, but it seems that that is not the case for blog-posts macro.

Anyone have any insight here?

1 answer

1 accepted

This widget could not be displayed.
Davin Studer Community Champion Nov 21, 2014

You sure could. You could create a user macro that checks the user's group and then it will create a blog-posts macro with the correct label. So in essence you wrap the blog-posts macro in a user macro and dynamically change out the label based on the user's group.

 

Update:

Here is an example user macro. Replace the HRGroup, ITGroup and AdminGroup with you group names. Add blocks if you have more groups. For each block put in the correct label. Also, replace the ??? on line 21 with your space's key.

## @noparams

#set $label = ""
#set($userGroups = $userAccessor.getGroupNamesForUserName($action.getAuthenticatedUser().name))

#foreach($group in $userGroups)
    #if($group == "HRGroup")
        #set $label = "hrlabel"
    #end
    #if($group == "ITGroup")
        #set $label = "itlabel"
    #end
    #if($group == "AdminGroup")
        #set $label = "adminlabel"
    #end
#end
#if($label != "")
<ac:structured-macro ac:name="blog-posts">
    <ac:parameter ac:name="content">titles</ac:parameter>
    <ac:parameter ac:name="spaces">
        <ri:space ri:space-key="???"/>
    </ac:parameter>
    <ac:parameter ac:name="reverse">true</ac:parameter>
    <ac:parameter ac:name="sort">creation</ac:parameter>
    <ac:parameter ac:name="labels">$label</ac:parameter>
</ac:structured-macro>
#end

...any references/guidance here in setting group parameters like that in a user macro?

Davin Studer Community Champion Nov 24, 2014

Check my edit above.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Sep 17, 2018 in Confluence

Why start from scratch? Introducing four new templates for Confluence Cloud

Hi my Community friends!  For those who don't know me, I'm a product marketer on the Confluence Cloud team - nice to meet you! For those of you who do, you know that I've been all up in your Co...

570 views 7 6
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