Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Finding BlockdataType using FindPagesWithCriteria



If you run the code using  eg\

var propCrit = new PropertyCriteriaCollection
                    new PropertyCriteria() {Name = "PageTypeID", Type = PropertyDataType.Block},


you pas the ID of the blockdata type, it will return with an exception that this is not supported.

So, now I'm left with the question; how can I search for all pages using a certain blockdata type?


Mar 26, 2013 15:46

You could use:

IContentModelUsage.ListContentOfContentType(ContentType contentType)

where the parameter contentType can be retrieved from IContentTypeRepository.Load(Type modelType) 

where you pass in the block type.

ListContentOfContentType will return both all shared block instances of the type and all content instances that has a property of the block type.

Mar 26, 2013 16:17

Great feedback Johan!

I found it also can be shortened a little (because in my case, I have the ID already)

 var usage = contentUsage.ListContentOfContentType(new ContentType{ID=contentID.ID});

Mar 26, 2013 17:27
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.