London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

How to filter out published blocks from code

Vote:
 

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?

 

Thanks!

#73038
Jul 04, 2013 14:52
Vote:
 

Hey,

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

Greetings, Martijn

#73056
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.