Try our conversational search powered by Generative AI!

List all block and which pages they are used on.



I have an admin module that when clicked shows a page that list all page types that has been built. When a page type is click a new page is shown that displays all links to all pages that are built on that page type. 

I would like to make similar admin module for block types. In short I would like to make two things:

A) I would like a page that display all block types that have been built.  

B) When a block type is clicked I would like to show a new page that displays links to all pages that are using that block type.

How do I make it. 

Aug 30, 2016 12:17

Block usage details:

In addition, to list all block types, use IContentTypeRepository:

var contentTypeRepo = ServiceLocator.Current.GetInstance<IContentTypeRepository>();

IEnumerable<ContentType> allBlockTypes = contentTypeRepo.List().Where(x => typeof (BlockData).IsAssignableFrom(x.ModelType));
Aug 30, 2016 12:47

Hi and thanks for the reply

However the links provided just refers to other links and refers to some interface, no example of how to implement the interfaces are shown anywhere. 

Aug 31, 2016 14:15

There already is a default implementation of the interfaces referred to and you can just inject them in your code (typically in the constructor of a Controller or other class) or by using ServiceLocator.

Example of dependency injection:

public class MyController : Controller
    private readonly IContentRepository _contentRepo;
    private readonly IContentModelUsage _modelUsage;

    public MyController(IContentRepository contentRepo, IContentModelUsage modelUsage)
        _contentRepo = contentRepo;
        _modelUsage = modelUsage;

Example of ServiceLocator in static class:

public static class SomeHelper
    public static void DoStuff()
        var contentRepo = ServiceLocator.Current.GetInstance<IContentRepository>();

        var modelUsage = ServiceLocator.Current.GetInstance<IContentModelUsage>();
Aug 31, 2016 15:50


Is there an equivilent to this for Episerver 6 R2?



Jul 13, 2018 10:35
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.