Our monthly Virtual Happy Hour is happening this week, Fri Feb 23!

Try our conversational search powered by Generative AI!

How to filter out published blocks from code


We are using this code to get all blocks:

var contentTypeRepository = ServiceLocator.Current.GetInstance<IContentTypeRepository>();
var contentModelUsage = ServiceLocator.Current.GetInstance<IContentModelUsage>();
var blockType = contentTypeRepository.Load<CertificationSubStepBlock>();
var allBlocks = contentModelUsage.ListContentOfContentType(blockType);


But we need just blocks which are published, and the code above retreives obsolate blocks from the trash too.

Can anybody help me with this?



Jul 04, 2013 14:52


Try some functions from in EPiServer.Filters. You probably need EPiServer.Filters.FilterForVisitor(...)

Greetings, Martijn

Jul 04, 2013 16:50
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.