Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Loading...
Area: Optimizely CMS
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

You can create a search solution to help website visitors find what they want by combining Episerver Data Source controls, listing controls and even third-party controls (.NET etc). If you require more extensive search functionality in your website solution, you can integrate third-party search engines with Episerver.

Searching for a page

The Episerver CMS SearchDataSource web control is a flexible web control enabling different types of searches in an Episerver CMS website. It can support text and property searches, and you can apply criteria to both types of searches.

Searching for pages often occurs in the following forms:

  • Text-based search (keywords) usually allow the user to input one or more keywords; any pages that contain those words should be returned and presented to the user.
  • Property-based search provides an efficient and powerful tool to retrieve pages based on any property values, typically of types other than string. From markup (or the visual design mode in Visual Studio), the Episerver SearchDataSource web control can support both types of searches; also different criteria can be applied to both types of searches.

    From code-behind files, you also can call the FindPagesWithCriteria() method of the EPiServer.DataFactory class to perform property-based searches. The FindPagesWithCriteria method is used by the SearchDataSource control when you perform a property-based search.

    From markup or visual design mode, add PropertyCriteria controls to the SearchDataSource tag. From code-behind files, create EPiServer.PropertyCriteria instances and insert them into a PropertyCriteriaCollection that is passed to the FindPagesWithCriteria method. You must add the SearchDataSource control's DataSourceID attribute to the control that renders the data.

Filtering information

A filter is a general mechanism in Episerver that is used to manage and manipulate information in listings and collections of content (PageDataCollection, IContent). As a developer, you can construct your own filters to use in conjunction with listings to display content. A filter is used for adding, removing, and sorting.

The following most common built-in filter options are as follows:

  • SortBy and SortDirection used to specify a custom property to sort on.
  • SortOrder uses a predefined sorting from FilterSortOrder enum.
  • MaxCount and SkipCount to limit number of items.
  • EnableVisibleInMenu, PageTypeID, and so on.
  • LanguageBranches collection to limit the search.
  • Criteria collection constrains the search result (used for property-search or as filters).
  • SelectParameters collection to set attribute values from other sources (Control, Cookie, Form, Profile, QueryString, Session, EPiServer Property).
  • FilterForVisitor works with IEnumerable<IContent> and PageDataCollection.

The Episerver filter classes and enumerations are documented in the  EPiServer.Filters namespace.

You can create your own filters by extending the EPiServer.Filters.IPageFilter class.

Do you find this information helpful? Please log in to provide feedback.

Last updated: Sep 21, 2015

Recommended reading