November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Block usage details: http://world.episerver.com/forum/developer-forum/Developer-to-developer/Thread-Container/2016/8/how-can-i-get-all-blocks-and-it39s-usages/
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));
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.
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>(); } }
Hi
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.