AI OnAI Off
You can use the IContentRepository for that
Check out
https://world.episerver.com/documentation/Class-library/?documentId=cms/10/72E612B0
This should give you a list of contents where the block is being referenced.
var contents = new List<ContentData>(); var repository = ServiceLocator.Current.GetInstance<IContentRepository>(); IEnumerable references = repository.GetReferencesToContent(contentLink, false); foreach (ReferenceInformation reference in references) { ContentReference ownerContentLink = reference.OwnerID; CultureInfo ownerLanguage = reference.OwnerLanguage; ILanguageSelector selector = new LanguageSelector(ownerLanguage.Name); var content = repository.Get<ContentData>(ownerContentLink, selector); var contentArea = content["ResponsibleEditors"] as ContentArea; if (contentArea != null) { if (contentArea.ContentFragments.Any(fragment => fragment.ContentLink == contentLink)) contents.Add(content); } }
I have an episerver project that has lots of blocks over time some of these blocks are no longer needed, is there a way to see if a created block is being used on any pages in my episerver project?
Potentially want to remove block types that will no longer be used from the code, but I'm not sure if it may break something down the line.