Quantcast
Channel: Using Optimizely Platforms
Viewing all articles
Browse latest Browse all 8020

List of pages that uses visitor groups

$
0
0

Hi, I'm trying to list all pages that uses visitor groups, similar to this report: https://world.episerver.com/blogs/Paul-Smith/Dates1/2011/8/Visitor-Group-Usage-Report/

I tried this code which works with one page.

var page = contentRepo.Get<IContent>(ContentReference.Parse("9"));

var isPersonalised = page.Property.Any(p => ((p as IPersonalizedRoles)?.GetRoles().Any() ?? false) ||
          (((p as PropertyContentArea)?.Value as ContentArea)?.Items?.Any(x => !string.IsNullOrEmpty(x.ContentGroup)) ?? false));

But I can't seem to find a way to get all pages and make it work.

I'm thinking something like this, if possible. 

foreach (var page in pages)
{
       var isPersonalised = page.Property.Any(p => ((p as IPersonalizedRoles)?.GetRoles().Any() ?? false) ||
                          (((p as PropertyContentArea)?.Value as ContentArea)?.Items?.Any(x => !string.IsNullOrEmpty(x.ContentGroup)) ?? false));

       if (isPersonalised)
       {
             usedOnThesePages.Add(page);

       }
}

Any suggestions?


Viewing all articles
Browse latest Browse all 8020

Trending Articles