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

Visible = true AND Status = Live AND Category.Contains("{Taxonomy ID}")

Visible = true AND Status = Live AND Category.Contains("{Taxonomy ID}") AND Category.Contains("{Taxonomy ID}")

Visible = true AND Status = Live AND (Category.Contains("{Taxonomy ID}") OR Category.Contains("{Taxonomy ID}"))

NOTE: You can view the ID of each classification by adding the Tags widget to a page, clicking its Edit button, deleting the contents of field TaxonomyID, and clicking Save.

Filter by tags

Visible = true AND Status = Live AND Tags.Contains("{Taxonomy ID}")

Visible = true AND Status = Live AND (Tags.Contains("{Taxonomy ID}") OR Tags.Contains("{Taxonomy ID}") )

Filter by custom fields (for Number custom field)

Visible = true AND Status = Live AND CustomFiledName > 0

Visible = true AND Status = Live AND CustomFiledName = 7

Filter by custom fields (for Choices custom field when Multiple choices can be selected)

Visible = true AND Status = Live AND CustomFiledName.Contains("value1")

Filter by custom fields (for Choices custom field when Multiple choices cannot be selected)

Visible = true AND Status = Live AND CustomFiledName = "value1"

Visible = true AND Status = Live AND CustomFiledName.StartsWith("value")

Filter by News title

Visible = true AND Status = Live AND Title.Contains("News Title")

Visible = true AND Status = Live AND Title.Contains("news")

Filter by News content

Visible = true AND Status = Live AND Content.Contains("ipsum")

Visible = true AND Status = Live AND Content.Contains("long established fact")

Filter by Author

Visible = true AND Status = Live AND Author = "author"

Visible = true AND Status = Live AND Author != " author"

Visible = true AND Status = Live AND Author.Contains("author")

Filter by publication date

Visible = true AND Status = Live AND PublicationDate <= DateTime.UtcNow // Shows all

Visible = true AND Status = Live AND PublicationDate < DateTime.UtcNow // Shows all

Visible = true AND Status = Live AND 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:

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

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:

Visible = true AND Status = Live AND EventStart > (01/01/2014) AND EventEnd < (04/01/2014)

 

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?