Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Don't display to roles View modes: 
User avatar
Member
Member
kphibbs-ibank - 6/12/2012 5:09:06 PM
   
Don't display to roles
Hi there,
I know there's an option of webparts to display to roles that are separated by semicolons. Is there an easy way of NOT displaying the web part to certain roles?

We have a lot of roles, and to have to set all web parts to show to all the roles except one specific one is a pain, and would be easier to list out the one or two roles the web part shouldn't show up for. Thanks for any help

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 6/12/2012 7:04:37 PM
   
RE:Don't display to roles
Hi,

Have you tried using a context macro or K# in the Visible field? This macro will check the current user role and return true/false value based on your rule (CurrentUser.IsInRole method).

Best regards,
Juraj Ondrus

User avatar
Member
Member
kphibbs-ibank - 6/12/2012 7:41:19 PM
   
RE:Don't display to roles
That worked, thanks!!

User avatar
Member
Member
lwhittemore-emh - 5/8/2013 9:24:29 AM
   
RE:Don't display to roles
{%CurrentUser.IsInRole("Collaborative")%}


This code yields

"True test false"

I am not sure what I am doing wrong.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 5/8/2013 10:28:34 AM
   
RE:Don't display to roles
Hi,

Have you tried using the macro debug to see how the macros are being resolved exactly?

Best regards,
Juraj Ondrus

User avatar
Member
Member
lwhittemore-emh - 5/8/2013 1:15:31 PM
   
RE:Don't display to roles
This is what comes out.

{%if (CurrentUser.IsInRole("Collaborative") == "True") { "is true" } else { "Is false" }%} Is false CMSAbstractWebPart.Render
CMSAbstractWebPart.StandardRender
CMSAbstractWebPart.get_ContentBefore
CMSAbstractWebPart.GetValueInternal
MacroResolver.ResolveMacros (2)
MacroResolver.ProcessMacros
MacroResolver.ResolveMacroHandler
MacroResolver.ResolveMacro
>CurrentUser.IsInRole("Collaborative")|(equals)True|(falsevalue)Is false|(truevalue)is true|(user)administrator|(hash)108484f935df2a79641dd97353fd9217a757629238feb0d59e29e1edd96f8fa7 True
>|(equals)True Is false
>|(falsevalue)Is false Is false
>|(truevalue)is true Is false
>|(user)administrator Is false
>|(hash)108484f935df2a79641dd97353fd9217a757629238feb0d59e29e1edd96f8fa7 Is false

It looks like I am loosing it at the (equals) part.

User avatar
Member
Member
kphibbs-ibank - 5/8/2013 1:31:05 PM
   
RE:Don't display to roles
This is what I used to get it to not display if the user is a member of a role:

{% !CurrentUser.IsInRole("<Name-Of-Role>") %}

The exclamation point being the "Not True" part if it. Not sure if that helps, but there you go.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 5/9/2013 10:21:45 PM
   
RE:Don't display to roles
Hi,

the true/false value and equals parameters are available to the old simple macros. Once you are using a method in the macro - it is more K# and you need to use the K# syntax to evaluate the expression, e.g. in an IF statement.

Best regards,
Juraj Ondrus