Connect Smart Search Filters

Vic Carter asked on September 8, 2014 18:58

I am using a custom country list for one of my smart search filters. I also have a state/province filter that displays for certain countries. What I would like to do is dynamically set the Query WHERE condition: for the smart filter webpart.

I have previously used CMS.GlobalHelper.RequestStockHelper to allow my country filter to show/hide my state filter, but I cannot find reference to the syntax for the Smart Search Filter WhereCondition.

The problem as I see it is that unlike normal webparts, which have controls as part of the layout, search filters are generated via code behind. Ideally if I had access to the file system I would just create a custom filter control. As it stands the only access I have to the code is via the layout property.

Here is an example of the code I would like to use:

<script runat="server">
  protected override void OnInit(EventArgs e)
{
   CMS.GlobalHelper.RequestStockHelper.Add("sFilter", this);
   base.OnInit(e);

  }

   protected override void OnLoad(EventArgs e) 
  { 
   base.OnLoad(e);

    if (drpFilter.Visible == false){ 
      drpFilter.SelectedIndex = 0;
    }else{
       string thisIndex = '+Countries:CAN';
      switch (thisIndex)
{
    case "+Countries:CAN":
       [WhereCondition] = "servicestate.Country = 'CAN'"
        break;
  case "+Countries:USA":
       [WhereCondition] = "servicestate.Country = 'USA'"
        break;
    case "+Countries:MEX":
        [WhereCondition] = "servicestate.Country = 'MEX'"
        break;
}  
    }
</script>

Correct Answer

Juraj Ondrus answered on December 6, 2014 10:49

Hi Vic,

You are right, the best way would be to have the access to the code behind files and customize them a bit. You were on the right path - something similar is described in this article.

Best Regards,
Juraj Ondrus

0 votesVote for this answer Unmark Correct answer

Recent Answers


Vic Carter answered on December 9, 2014 14:54

Thank you Juraj, I resolved this a while back, but that article will definitely help me in the future.

0 votesVote for this answer Mark as a Correct answer

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