More in this section

Forums / Developing with Sitefinity / ContentView - filtering

ContentView - filtering

6 posts, 1 answered
  1. Andree
    Andree avatar
    44 posts
    Registered:
    11 Jan 2010
    10 Feb 2010
    Link to this post
    Hi Ivan,

    I need some advice on building some filters for the ContentView, as I'm getting some really odd results come back from my own filtering.

    To allow a content item to be a part of multiple categories, I have created 5 meta fields called:

    Category1
    Category2
    Category3
    Category4
    Category5

    Each content item also has a meta field called "Title". Within my ContentView, a user can filter down by Category and by Keywords. So for example, if a user wanted to search for a content item with the title containing "Weekly reports", from the category "Marketing", the filtering statement would have to look like:

    ((Category1 = "Marketing" OR Category2 = "Marketing" OR Category3 = "Marketing" OR Category4 = "Marketing" OR Category5 = "Marketing") AND Title LIKE "Weekly reports")

    Having had a fiddle with the ContentFilterBuilder, I've had some odd results having the multiple Category OR statements, resulting in content items being duplicated 7 or 8 times.

    Could you give me some example code on how I should use the ContentFilterBuilder to generate a similar filtering statement to above?

    Regards,
    Alvaro

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Feb 2010
    Link to this post
    Hi Alvaro,

    Nolics ORM does not support "OR" condition. Below is a sample that illustrates how to use ContentFilterbuilder class

    ContentFilterBuilder filterBuilder = new ContentFilterBuilder(this);
    filterBuilder.AddFilter(new ContentFilterStatement("Category", categoryNames,
    ContentFilter.Condition.In, ContentFilter.JoinType.And));


    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
    Answered
  3. Andree
    Andree avatar
    44 posts
    Registered:
    11 Jan 2010
    10 Feb 2010
    Link to this post
    Hi Ivan,

    In that case, can you explain to me what the ContentFilter.JoinType.Or enumerator is for?


    Regards,
    Alvaro
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Feb 2010
    Link to this post
    Hi Alvaro,

    ContentFilterJoinType based on the IMetaSearchInfo JoinType property. You cannot use OR type to filter the items. You will get incorrect results. We will support OR condition from 4.0 where we are going to use Open Access ORM. You can achieve filtering based on Or condition by creating two list where you have two conditions. Each of these conditions should checks  whether the item ID exists or not in the fists list. This will resut in the performance of the page load especcaly if you have lots of articles.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  5. Andree
    Andree avatar
    44 posts
    Registered:
    11 Jan 2010
    10 Feb 2010
    Link to this post
    Hi Ivan,

    Many thanks for the explanation, I will probably adapt the way we handle the categories on some of our content to return to a single category again.


    Regards,
    Alvaro
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    10 Feb 2010
    Link to this post
    Hi Alvaro,

    Always glad to help. I hope that 4.0 will resolve completely such issues.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Register for webinar
6 posts, 1 answered