Khoros Community

Highlighted
Esteemed Contributor
Esteemed Contributor

Banner or notification for specific roles

From time to time I want to put a notice or banner up on the home page and/or node pages that is only viewable by people with a certain role.  For example I want to put a big notice, hard to miss, about some important community changes that is only viewable to company employees (have the employee role).

Is that possible and what's the best/easiest way to do that?    Thanks  - Kim

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
Tags (1)
0 Kudos
6 Replies 6
Honored Contributor
Honored Contributor

Re: Banner or notification for specific roles

@kgroneman - If you want to display a banner for users who have ceartin roles, then you need to use the following code inside the custom component.

<#assign isEmployee = false />
<#list restadmin("/users/id/${user.id?c}/roles").roles.role as mainrole>
<#if mainrole.name?? && (mainrole.name == "Employee")>
<#assign isEmployee = true />
<#break>
</#if>
</#list>

<#if isEmployee>

..........................................YOUR BANNER CODE/COMPONENT.............................................

</#if>

Please let me know if this helps.

Thanks!

Reply
Loading...
Esteemed Contributor
Esteemed Contributor

Re: Banner or notification for specific roles

I'll give that a try. Thanks!


--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
0 Kudos
Reply
Loading...
Khoros Guru
Khoros Guru

Re: Banner or notification for specific roles

The Announcement feature accepts freemarker code in the content as well, so you don't even need to deploy a new custom content widget or similar, but can directly drop it via community admin in the announcement.


Khoros Best Practice until August 2019. Onwards posting as Claudius.
Learn how to master Khoros. Learn Best Practice in the Community Documentation
If you appreciate my efforts, please give me a kudo ↓
Accept as solution to help others find it faster.
Reply
Loading...
Esteemed Contributor
Esteemed Contributor

Re: Banner or notification for specific roles

@ClaudiusH  thanks, but I'm not a developer, and we don't have one on staff, so I have no clue how to use freemarker to do it. 😞

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
0 Kudos
Reply
Loading...
Trusted Contributor
Trusted Contributor

Re: Banner or notification for specific roles

@kgroneman Try putting this code a custom content or the announcements box within a page:  You would just need to update ROLEA, ROLEB, ROLEC to the roles you want to see this, and then add the appropriate text, image, code, to where i said so in the code below.

 

<#attempt>
<#assign user_has_role = false />
<#if user.registered >
<#list restadmin("/users/id/${user.id?c}/roles").roles.role as role>
<#if role.name?? && (role.name == "ROLEA" || role.name == "ROLEB" || role.name == "ROLEC")>
<#assign user_has_role = true />
</#if>
</#list>
</#if>
<#if user_has_role >

*THIS IS WHAT WILL DISPLAY IF THEY ARE IN THE ROLE*

<#else>

*THIS IS WHAT DISPLAYS IF THEY ARE NOT IN ONE OF THOSE ROLES*


</#if>
<#recover> 
<!-- Something bad happened -->
</#attempt>

 

Reply
Loading...
Esteemed Contributor
Esteemed Contributor

Re: Banner or notification for specific roles

Thanks.   I'm up to my eyeballs in other stuff right now but hope to get around to trying this out next week.   I REALLY appreciate your input @StanGromer @ClaudiusH  @Payal 

--
Community manager in the Micro Focus Community. My computer always used to beat me at chess, but it is no match for me now I changed the competition to kick boxing.
0 Kudos
Reply
Loading...