Filter expressions for content items

Following is a list of examples of filter expressions’ syntax. You can use these examples to create your own filter expressions when you configure the widgets.

Filter by category

C#
Category.Contains("{Taxonomy ID}")
Category.Contains("{Taxonomy ID}") AND Category.Contains("{Taxonomy ID}")
(Category.Contains("{Taxonomy ID}") OR Category.Contains("{Taxonomy ID}"))

NOTE: To view the ID of each classification, add the Tags widget to a page, click its Edit button, delete the contents of field TaxonomyID, and click Save.

Filter by tags

C#
Tags.Contains("{Taxonomy ID}")  
(Tags.Contains("{Taxonomy ID}") OR Tags.Contains("{Taxonomy ID}"))

Filter by custom fields (for Number custom field)

C#
CustomFiledName > 0
CustomFiledName = 7

Filter by News title

C#
Title.Contains("News Title")
Title.Contains("news")

Filter by News content

C#
Content.Contains("ipsum")
Content.Contains("long established fact")

Filter by Author

C#
Author = "author"
Author != " author"
Author.Contains("author")

Filter by publication date

C#
PublicationDate <= DateTime.UtcNow // Shows all
PublicationDate < DateTime.UtcNow // Shows all
PublicationDate > DateTime.UtcNow // Shows none

Filter by date logged

To filter only items where the date component of the value specified in the DateLogged field matches the date component of DateTime.UtcNow use:

C#
Visible = true AND Status = Live AND DateLogged.HasValue AND DateLogged.Value.Date = DateTime.UtcNow.Date

Filter by event dates

To filter events by EventStart and EventEnd dates, for example events that from 1st of January 2014 and end till 4th of January 2014 use:

C#
EventStart > (01/01/2014) AND EventEnd < (04/01/2014)
Want to learn more?
Enhance your Sitefinity skills by enrolling in free training sessions. Become Sitefinity certified through Progress Education Community to strengthen your professional credentials.