开发者

SharePoint 2010 Two search boxes on the master page

I would like to have two search boxes on my master page. One that would search for content and the other one that would search for people.

I see the code in the master page that searches for content:

How would i do to add another box that searches for people?

if you know or have info on how to achieve this I would appreciate it. t开发者_开发技巧hank you much W


You can do something simple which is to put an HTML text box directly in your master page. It may not be as elegant as writing a customer user control that reads the location of the Search site, but if the URL to your search results page is static then something like this might work for you:

<script type="text/javascript">
function SearchPeople()
{           
    var termArr = document.getElementById("SearchTextBoxPeople").value.split(" ");
    var retStr = "";
    for (var i = 0; i < termArr.length; i++) {
        retStr += termArr[i] + "* ";
    }
    document.location.href = "/Search/Pages/peopleresults.aspx?k=" + retStr;
}
</script>

<input type="text" id="SearchTextBoxPeople" />
<a href="#" onclick="SearchPeople();">Search People</a>

One additional benefit of this is that you can control the input to include wildcards (which are horrible out-of-the-box for people searches). The JavaScript is simply including * in the search which allows wildcard searches. So a search for jo sm will actually send jo* sm* to the search page which will then match on John Smith.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜