Take the community feedback survey now.
                AI OnAI Off
            
        Take the community feedback survey now.
 
                I iterate all vistor groups used in my Visitor Group Usage gadget. Take a look at:
For some inspiration.
Hi
Thanks for the inspiration. Now i have installed your gadget. I hope my editors will like it. I think it is very helpful.
Thanks to you i now have a code that works. But my code uses currentContentArea.Contents witch is obsolute. Did not find a good solution for that. Do you have a solution?
        public override ActionResult Index(SiteBlockData currentContent)
        {
            if (PageEditing.PageIsInEditMode)
            {
                var currentContentArea = ControllerContext.ParentActionViewContext.ViewData.Model as ContentArea;
                if (currentContentArea != null)
                {
                    var visitorGroupRepo = ServiceLocator.Current.GetInstance<IVisitorGroupRepository>();
                    //Find currentContent in content area. Any better way of doing this?
                    int index = currentContentArea.Contents.IndexOf(currentContent as IContent);
                    var item = currentContentArea.Items[index];
                    if (item.AllowedRoles != null)
                    {
                        var names = String.Empty;
                        var counter = 0;
                        foreach (var group in item.AllowedRoles)
                        {
                            counter++;
                            var vg = new Guid(group);
                            var loadedVg = visitorGroupRepo.Load(vg);
                            if (loadedVg != null)
                            {
                                if (counter == 1)
                                {
                                    names = visitorGroupRepo.Load(vg).Name;
                                }
                                else if (counter < item.AllowedRoles.Count())
                                {
                                    names = names + ", " + visitorGroupRepo.Load(vg).Name;
                                }
                                else
                                {
                                    names = names + " and " + visitorGroupRepo.Load(vg).Name;
                                }
                            }
                        }
                        currentContent.VisitorGroups = names;
                    }
                }
            }
            return PartialView(string.Format("~/Views/Shared/Blocks/{0}.cshtml", currentContent.GetOriginalType().Name), currentContent);
        }
View
@using EPiServer.Editor
@model SiteBlockData
@if (PageEditing.PageIsInEditMode && !String.IsNullOrEmpty(Model.VisitorGroups))
{
    <p>Visible to: @Model.VisitorGroups</p>
}
Any other feedback?
 
    
    
    
Hi
I am trying to render a blocks visitor groups. Anybody know how to do this? Since Blocks will be personalised for every contentarea they are used on. I have created a Ignoe field on the block model that i want to render a string showing the personalization informasjon.
I am thinking that i can get the information i need in the block controller
Anybody?