Forum Discussion

PerBonomi's avatar
11 years ago

Sideloading different css

I have had several requests to show/hide certain elements depending on what kind of user is logged in.   E.g. super users want to see all the columns, but a new user doesn't need to see the new pos...
  • nathan's avatar
    nathan
    11 years ago

    I'm not aware of an option for hiding the new column.

     

    If you just want to hide it from view then you could use CSS. This won't remove the content from the source code though (so it's not secret).

     

    You can make this CSS dependant on the user's role by wrapping it in some FreeMarker.

     

    Here is an example of code that would hide the New column unless the user has the moderator role.

     

    <style>
    <#if user.anonymous == true>
    .newMessageCountColumn {
        display: none;
    }
    <#else>
       <#assign user_has_role = false />
       <#list restadmin("/users/id/${user.id?c}/roles").roles.role as role>
          <#if role.name?? && (role.name == "Moderator")>
             <#assign user_has_role = true />
          </#if>
       </#list>
       <#if !user_has_role >
          .newMessageCountColumn {
            display: none;
          }
       </#if>
    </#if>
    </style>

    (Code borrowed from this page: http://community.lithium.com/t5/Developers-Knowledge-Base/Using-FreeMarker-expressions-to-personalize-announcements-and/ta-p/7427 )