AI OnAI Off
Hi Mark,
You could loop through the properties on the content and check whether each property is of type IPersonalizedRoles and, if so, check whether there are any roles defined using .Roles(). If it's not an IPersonalizedRoles, check if it's a ContentArea and, if so, check if any of its items have the ContentGroup set. Something like this:
var isPersonalised = myContent.Property.Any(p => ((p as IPersonalizedRoles)?.GetRoles().Any() ?? false) ||
(((p as PropertyContentArea)?.Value as ContentArea)?.Items?.Any(x => !string.IsNullOrEmpty(x.ContentGroup)) ?? false));
Paul
You can use the Visitor Group Usage Viewer and check the source code ;): https://www.david-tec.com/2017/12/visitor-group-usage-viewer-for-episerver-11/
To be fair, that's the post that introduced me to the IPersonalizedRoles interface.
Is there an API or way to understand whether a piece of content is configured with visitor groups ?
I don't care what those groups are or whether an http request would match any of those groups. I just want to find a way of knowing whether content properties are personalised (ie, content areas, or rich text blocks)