kentico_michal
-
2/16/2011 2:51:40 AM
RE:Smart search - Filter by document path ? (Newbie question)
Hi David,
This is not possible to achieve using Smart search filter. I would recommend using different approach. Smart Search Results web part has property called Path, where you can specify the section from content tree where documents will be searched. So you will need to change this property dynamically.
One way could be based on modifying Smart Search Dialog control (~\CMSModules\SmartSearch\Controls\SearchDialog.ascx), which is used in Smart Search Dialog web part. You could add simple RadioButtonList/DropDownList to this control and fill it with values of nodoaliaspath parameters according to your needs:
<asp:RadioButtonList ID="rblist" runat="server"> <asp:ListItem Text="Articles" Value="/Articles/%" /> <asp:ListItem Text="People" Value="/People/%" /> <asp:ListItem Text="All" Value="" /> </asp:RadioButtonList>
Selected value needs to be added to the current url as a query parameter when user clicks the search button. Therefore you will need to add following code into btnSearch_Click method in the code behind:
else { url = UrlHelper.AddParameterToUrl(url, "searchmode", SearchHelper.GetSearchModeString(SearchMode)); }
// START url = UrlHelper.RemoveParameterFromUrl(url, "param"); if (!rblist.SelectedValue.Equals("")) { url = UrlHelper.AddParameterToUrl(url, "param", rblist.SelectedValue); } // END
In order to apply this query parameter in Smart Search Results web part you can use query macro in Path property of the Smart Search Results web part:
Path: {%param%}
This is just a simple example that suppose combination of Smart Search Dialog and Smart Search Results web parts, but I hope you get an inspiration.
Michal Legen, Best regards
|