Try our conversational search powered by Generative AI!

Getting a page with a specific value

Vote:
 

Hello,

I'd like to get all the pages of a specific pagetype and filter them based on a property value. I'm guessing that I have to use the FindPagesWithCriteria method, but im not sure how to properly request all the pages of a specific type, and then filter that via LINQ on a specific property value of my choosing.

Any help is much apprechiated!

Thanks.

#87515
Jun 16, 2014 11:34
Vote:
 

Hi,

This is the code for the page type criteria.

If you want to get the id of a specific page type and only have the page type class, you can work with the PageTypeRepository - ServiceLocator.Current.GetInstance<PageTypeRepository>()

PropertyCriteria criteria = new PropertyCriteria();
criteria.Condition = CompareCondition.Equal;
criteria.Name = "PageTypeID";
criteria.Type = PropertyDataType.PageType;
criteria.Value = idOfPageType;
criteria.Required = true;

Also add your other criteria based on what kind of value you have on the property.

There are some good get-started blog posts about FindPagesWithCriteria:

http://www.frederikvig.com/2009/10/episerver-findpageswithcriteria-and-findallpageswithcriteria/

http://tedgustaf.com/blog/2010/5/search-episerver-pages-using-findpageswithcriteria/

Note!
Remember to cache your result since FindPagesWithCriteria makes a request directly to the database.

#87517
Jun 16, 2014 12:12
Vote:
 

Thanks alot Alf!

#87518
Jun 16, 2014 12:48
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.