+1-888-365-2779
Try Now
More in this section
Categories
Bloggers
Blogs RSS feed

Filter Expressions

by Georgi Chokov
One of Sitefinity 3.5’s new features is Filter Expressions. These enable you to show content based on conditions, such as publication date, category, and the module’s meta fields. All of the Generic Content Based modules, which include News, Blogs, Events and Images and Documents, support filter expressions.


To access a filter expression, simply drag one of the Generic Content Based modules public controls onto the form, such as a NewsView, click on the advanced tab and then the filter tab. By default, the filter expression filters on a valid publication and expiration date as shown below this sentence:

 
Publication_Date <= "#now" AND Expiration_Date > "#now"

 
You can use filter expressions in a variety of ways and you can combine multiple conditions. For example, you can show all content published before today, with an expiration date that’s valid, where the category is MyCategory and the tag is mytag as shown below this sentence:

 
Publication_Date <= "#now" AND Expiration_Date > "#now" AND Category IN ("MyCategory") AND Tag.Name = "mytag"

 
To filter by specific dates, use this syntax:

 
Event_Start >= "1/1/2008" AND Event_Start < "12/31/2008"

 
Filter Expressions support a variety of SQL operands, joins and conditions. For a full list of them, please review this forum post.

 
You can filter by a variety of fields in the generic content based modules. Using the Events module as an example, you could filter by event start and event end. For a more complete list of fields in the Events Module, please review this article. You could also add and find a list of meta fields by viewing in your Web.config. 

9 comments

Leave a comment
  1. Romi Dec 22, 2008
    Hi Joseph,
    Thanks for this complementary explain. Could you go more in the abyss and suggest us one searching multi dropdown box as UC to get the items by selecting the Metafields and using AND or OR to see the news. Select Category like and Author as  for  Date to Date. I understand that you can put that as filter expression but could you suggest the complete way to build this usefull userControl selecting provider to use, metafields in this provider expose to dropdown and get resulting as jquery in same window. Wow this is Sitefinity. Thanks.
  2. Joe Dec 29, 2008
    Hi Romi, thanks for the suggestion. We will try to make some blog posts about something like this in the future.
  3. Joseph Anderson Jan 07, 2009
    In this case, Romi, you should create a complex type editor for the filter expression property. To give you an overview, you would populate a list with information, such as possible filter expressions. Then, populate a drop down list with that information, implementing some custom logic to ensure that the datasource is not null or empty.  For more info, please read this blog post from my colleague Ivan Osmak. In this sample, you could remove 3 of the 4 classes in the QuotesData.cs and just populate the last class with filter expressions. That would be most of the work.
  4. energy meter Mar 07, 2011
    I think the point is the allocation of resources and priorities.
  5. Dr. Gil lederman May 21, 2013
    really very effective
    and to the point
  6. Hosted PBX Jun 06, 2013
    Nice thoughts I like your views. Kindly update your views on
    daily bases.
  7. Hosted Pbx Jun 12, 2013
    I appreciate your thoughts and way of sharing details like this with others.
  8. sgilani Jun 19, 2013
    Logo designing
  9. Web designing and development Jul 15, 2013
    A lot of the comments on this blog show that there is complete ignorance about these things

    Leave a comment