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>
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
Thank you Juraj, I resolved this a while back, but that article will definitely help me in the future.
Please, sign in to be able to submit a new answer.