Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
I think that you can just create an initializationmodule, find the contenttype(using ContentTypeRepository) and set IsAvailable to false and save it.
Thanks Josef, it worked.
I added a module like this
[InitializableModule] [ModuleDependency(typeof(EPiServer.Web.InitializationModule))] public class DisableBuiltInContentTypesInitializationModule : IInitializableModule { public void Initialize(InitializationEngine context) { var contentTypeRepository = ServiceLocator.Current.GetInstance<IContentTypeRepository>(); var customizedSearchBlock = contentTypeRepository.Load<CustomizedSearchBlock>(); if (customizedSearchBlock != null && customizedSearchBlock.IsAvailable) { var clone = customizedSearchBlock.CreateWritableClone() as ContentType; clone.IsAvailable = false; contentTypeRepository.Save(clone); } } public void Uninitialize(InitializationEngine context) { } }
Yes Valdis master of DI, please show me how to do it in a init module without that ;-)
I will buy you a beer if you show me....
Oh, I actualy can! Well it still somehow uses the servicelocator, but should still be more correct
[InitializableModule] [ModuleDependency(typeof(EPiServer.Web.InitializationModule))] public class DisableBuiltInContentTypesInitializationModule : IInitializableModule { public void Initialize(InitializationEngine context) { var contentTypeRepository = context.Locate.Advanced.GetInstance<IContentTypeRepository>(); var customizedSearchBlock = contentTypeRepository.Load<CustomizedSearchBlock>(); if (customizedSearchBlock != null && customizedSearchBlock.IsAvailable) { var clone = customizedSearchBlock.CreateWritableClone() as ContentType; clone.IsAvailable = false; contentTypeRepository.Save(clone); } } public void Uninitialize(InitializationEngine context) { } }
So the important part her, according to Quan Mai if I remember right, is to use the context to get get servicelocator to get the instance... wonder why that is important
I'm just trolling you guys, sorry. btw, `context.Locate.Advanced` is just a hideout for the ServiceLocator :)
but you got me hooked. i''ll look for a way to do this with DI.
at the end... free beer is free beer!!
And a quick fix (before you implement the code to hide it in your next sprint :D) to hide it, is to login to admin view:
Content types tab -> under block types -> click: customized search
I noticed that the block type Customized Search is available for all editors and I do not want my editors to use that block type.
How do I hide or delete it?