I recently reviewed an implementation of a custom search control placed within the master page within a SharePoint application. The control redirected to a hard-coded search page URL, one that did not correspond to the general search results page used within the portal.
To ensure that a single shared search results page is used, add the following feature to your site definition:
1: <SiteFeatures>
2: <!-- SearchCenter Url feature -->
3: <Feature ID="7AC8CC56-D28E-41f5-AD04-D95109EB987A" >
4: <Properties xmlns="http://schemas.microsoft.com/sharepoint/">
5: <Property Key="SearchCenterUrl" Value="~SiteCollection/Pages/Search.aspx" />
6: </Properties>
7: </Feature>
8: </SiteFeatures>
The redirect handler is then changed to:
1: /// <summary>
2: /// Called when site search input text has changed.
3: /// </summary>
4: /// <param name="sender">The sender.</param>
5: /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
6: private void OnSiteSearchTextChanged(object sender, EventArgs e)
7: {8: if (!string.IsNullOrEmpty(SiteSearch.Text) &&
9: SPContext.Current != null)
10: {11: Response.Redirect(string.Format("{0}?k={1}",
12: SPContext.Current.Site.RootWeb.AllProperties["SRCH_ENH_FTR_URL"],
13: SiteSearch.Text)); 14: } 15: }
0 comments:
Post a Comment