Reputation: 1256
I have an alert section pulling items with a repeater. My transformation pulls date and copy and displays them in UL tags.
I've been asked to make a change where a specific alert would only be seen by people is a specific group/role.
My thoughts were change the page type form with a check box. On the transformation side i would then need a conditional statement where the check box is true and the user is part of specific Role.
My transformation is currently an ASCX and is as follows:
<li><%# Eval("Alert") %></li>
I imagine it being something like this
<% if ( checked = true && role = XX ) { <li>Eval("Alert")</li> } %>
I just can't figure out the conditional statement.
Upvotes: 1
Views: 360
Reputation: 331
For Text/XML transformation
{% if(checked == true && CurrentUser.IsInRole("MyRole")) {return "<li>" + Alert + "</li>"} %}
ASCX
<%# If(CMS.Membership.MembershipContext.AuthenticatedUser.IsInRole("rolename", CMS.SiteProvider.SiteContext.CurrentSiteName) && Eval("checked") == true, "<li>" + Eval("Alert") + "</li>","") %>
Upvotes: 3
Reputation: 1549
I'd recommend to add some CSS class based on your condition:
<li class="<% if(Eval<bool>("FieldsName") &&
CMS.Membership.MembershipContext.AuthenticatedUser.IsInRole("rolename", CMS.SiteProvider.SiteContext.CurrentSiteName);) {"alert"} %>">
....
</li>
Having "alert" class added to your li, you can change visibility, colors or whatever you need for that item.
This approach requires ASPX transformation.
Upvotes: 1
Reputation: 470
You can use the method CurrentUser.IsInRole(, )
I came up with something like:
<%# (checked && CurrentUser.IsInRole("_everyone_", "corporate") ? Eval("DocumentName") : "empty") %>
David
Upvotes: 0