I am new to the episerver CMS. I have got the list of pages associated with a category using property criteria. Like that I need to list all the blocks in a site by a particular category, Is there any options available to do this using criteria or any builtin methods available.
Here I have attached the code i did for filtering the pages by category.
PropertyCriteriaCollection criterias = new PropertyCriteriaCollection();
PropertyCriteria criteria = new PropertyCriteria();
criteria.Condition = CompareCondition.Equal;
criteria.Name = "PageTypeID";
criteria.Type = PropertyDataType.Category;
criteria.Value = "Sublevel1";
criteria.Required = true;
PageDataCollection pageList = Locate.PageCriteriaQueryService().FindPagesWithCriteria(PageReference.RootPage, criterias);
In the pageList i got all the pages with the category "Sublevel1", How to modify this code to get blocks ?
Can anyone help me.
Thanks in advance.
What you can do is to get all the blocks using contentRepository like described in this thread http://world.episerver.com/Forum/Developer-forum/EPiServer-7-CMS/Thread-Container/2012/11/Get-all-the-instances-of-a-block-type/
You can use your block base page as the type to filter by or Episerver's if you don't have any.
Then using LINQ on the result collection you can filter to get those that have the "Sublevel1" category that you need.
Hope it helps!