Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Smart search - Filter by document path ? (Newbie question) View modes: 
User avatar
Member
Member
dfurler-liv.asn - 2/14/2011 7:21:19 PM
   
Smart search - Filter by document path ? (Newbie question)
Hello, excuse the dumb question but I have been searching the forums and documentation without any luck.

I just want to use the smart search filter to only search a section of a site.

For example, if I have a menu structure with say:

/Articles
/People
/Bookshop

Etc. I would like to fill in the values of the dropdown menu, with what I imagine to be something like:

document.path ; /articles/% ; Articles

Any help would be most appreciated.

Thanks,
David

User avatar
Member
Member
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

User avatar
Member
Member
dfurler-liv.asn - 2/20/2011 4:20:23 PM
   
RE:Smart search - Filter by document path ? (Newbie question)
Hello Michal,

Apologies for the late reply, I have been on leave.

Just wanted to say thanks for your comments though, this will be exactly what I need Im sure.

Regards,
David