Using SearchFilter with SearchResults

Alexander Pinin asked on May 31, 2017 14:28

Hi everyone!
I'm using a set of Kentico controls: SearchDialog, SearchFilter, SearchResults.
I can't figure out how to use ID links between these controls.
There is my code:

<cms:SearchDialog  ID="SearchDialog1"  FilterID="SearchFilter1" />
<cms:SearchFilter  ID="SearchFilter1"  SearchWebpartID="SearchDialog1" />
<cms:SearchResults ID="SearchResults1" />

Is this way correct?
Looks like the SearchFilter does not affect on the SearchResults.

Recent Answers


Brenden Kehren answered on May 31, 2017 14:42 (last edited on May 31, 2017 15:21)

The filters are tied to the results not the dialog. So in your SearchFilter1, set the SearchWebpartID = SearchResults1 vs. the dialog.

1 votesVote for this answer Mark as a Correct answer

Prashant Verma answered on May 31, 2017 14:44 (last edited on May 31, 2017 15:09)

Hi Alexander,

The way you are call is some what correct only the thing which I believe is missing FilterMode type of your filter.

<cms:SearchDialog  ID="SearchDialog1"  FilterID="SearchFilter1" />
<cms:SearchFilter  ID="SearchFilter1"  SearchWebpartID="SearchDialog1"  FilterMode="Text box"/>
<cms:SearchResults ID="SearchResults1" />

Thanks

Happy to help you

2 votesVote for this answer Mark as a Correct answer

Prashant Verma answered on May 31, 2017 15:01 (last edited on May 31, 2017 15:02)

I guess Brenden pointing right thing but not fully correct it should be like this because Alex using two different control i.e. Search Dialog and Search Result.

filters are tied to dialog and dialog tied to result. So in your SearchFilter, set the SearchWebpartID = SearchDialog and in SearchDialog, set the ResultWebpartID = SearchResults.

<cms:SearchDialog  ID="SearchDialog1"  ResultWebpartID="SearchResults1" />
<cms:SearchFilter  ID="SearchFilter1"  SearchWebpartID="SearchDialog1"  FilterMode="Text box"/>
<cms:SearchResults ID="SearchResults1" />

Thanks

Happy to help you

0 votesVote for this answer Mark as a Correct answer

Alexander Pinin answered on May 31, 2017 15:38 (last edited on May 31, 2017 15:39)

Prashant and Beander, thank you!
Actually I'm setting the FilterMode and this is the DropdownList.
And I'm setting to the FilterValues property the value PublishFrom DESC;;PublishFrom. It should order my results by date. But it does not work.
The PublishFrom property exists and when I do this SearchResult.SearchSort = "PublishFrom DESC" it works. What could be wrong?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 31, 2017 15:53

You're setting the values of a filter to an order by clause and not a something which could be translated into a where clause. Filter values are essentially building a where clause for the Smart Search to limit your results. Filter values are NOT meant to provide sorting or ordering on results.

0 votesVote for this answer Mark as a Correct answer

Alexander Pinin answered on May 31, 2017 16:02 (last edited on May 31, 2017 16:03)

I've read this part of the documentation Using search filters. The Search result order filters section. Looks like I misunderstood it.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 31, 2017 16:08

No, you read that right, problem is we're only getting bits and pieces to a multi-part question. If you're using the filter for sorting, then you need to ensure Filter is conditional = false on the smartsearch results webpart for the filter to work properly AND remove the SearchSort property value.

1 votesVote for this answer Mark as a Correct answer

Alexander Pinin answered on May 31, 2017 16:29 (last edited on May 31, 2017 16:30)

Brenden, I'm very sorry for not a fully-formulated question. I was sure the problem was with ID and asked about it at first.
Actually I'm trying to figure out how the SearchFilter works.
In one case before I used SearchDialog, SearchResults and method to sort It using SearchSort property.
But now I would like to use out of the box functionality of the SearchFilter (without SearchSort). I'm trying to apply different options but I have no results.
If I understood you correctly this code should sort my results, right?

    SearchFilter1.FilterMode = SearchFilterModeEnum.DropdownList;
    SearchFilter1.FilterIsConditional = false;
    SearchFilter1.FilterValues = "PublishFrom DESC;;PublishFrom";
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.