November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
You need to check if the blocks are published, here's is how you can do it:
var blockType = contentTypeRepository.Load<RequisitionBlock>();
var contentUsages = contentModelUsage.ListContentOfContentType(blockType);
var contentReferences = contentUsages.Select(x => x.ContentLink.ToReferenceWithoutVersion()).Distinct().ToList();
var instances = new List<IContent>();
foreach (var contentReference in contentReferences)
{
var content = contentLoader.Get<IContent>(contentReference);
var isPublished = contentRepository.TryGet<IContent>(contentReference, out var publishedContent);
if (isPublished)
{
instances.Add(publishedContent);
}
}
I'm using this code to get the block data.
The usages bring up 9 items and as it gets to instances, it filters to 5 items. But there's only one active item on the site. I've deleted the rest. How can I filter out the deleted blocks?