SharePoint Site Search Settings (Search Scope DropDown)

Today I was working on some SharePoint master pages and I noticed that the search scopes dropdown was gone. After searching around in the site collection administration settings I found a setting under the ‘search settings’ link.

searchsetting

The property ‘Site Collection Search Dropdown Mode’ can be set to several options. Default this property is set to ‘Do not show scopes dropdown, and default to contextual scope’. In this setting you have the following options: Do not show scopes dropdown, and default to contextual scope. You will get result of the ‘All Sites’ scope when you are at the top level. If you are in another level you will get results from your context. Do not show scopes dropdown, and default to target results page The search results will be displayed as described above. It will only use your target result page for displaying the results. Show scopes dropdown Display’s the scopes that are defined in the scope display group of the site. Show, and default to ’s’ URL parameter Displays the scopes that are defined in the scope display group of the site. This option will add the scope to the query string using the ‘s’ parameter. Show and default to contextual scope Displays the scope drop-down list and selects the “This site” and “This list” by default. Show, do not include contextual scopes This option will not display the contextual scopes. Show, do not include contextual scopes, and default to ’s’ URL parameter This option will not display the contextual scopes, and will also send the scope within the query string using the ‘s’ parameter. These settings can all be set trough the UI but in most situations we as developers need to set these properties within a feature receiver. When you search through the object model you will not find a possibility off doing it through code. The next option is to look with reflector in the code behind of the page and you will find a way to accomplish this task. Each site or web has a property bag by setting the “SRCH_ENH_FTR_URL” you set the search site URL of the site collection. And by setting the “SRCH_SITE_DROPDOWN_MODE” property you change the display mode of the search dropdown. Here below you can find an example in code:

 private void ApplySearchSettings(SPWeb web)
 {
       if(web.IsRootWeb)
       {
            string searchCenterUrl = (new Uri(web.Url).GetLeftPart(UriPartial.Authority)) + "searchcenter";
            web.AllProperties["SRCH_SITE_DROPDOWN_MODE"] = "ShowDD_DefaultContextual ";
            web.AllProperties["SRCH_ENH_FTR_URL"] = searchCenterUrl;
            web.Update();
       }
 }

The property “SRCH_SITE_DROPDOWN_MODE” has several options you can fill in:

  • HideScopeDD – Do not show scopes dropdown, and default to contextual scope.
  • HideDD_NoScope – Do not show scopes dropdown, and default to target results page.
  • ShowDD – Show scopes dropdown.
  • ShowDD_DefaultURL – Show, and default to ‘s’ URL parameter.
  • ShowDD_DefaultContextual – Show and default to contextual scope.
  • ShowDD_NoContextual – Show, do not include contextual scopes.
  • ShowDD_NoContextual_DefaultURL – Show, do not include contextual scopes, and default to ‘s’ URL parameter

For the scopes dropdown modes you can also look at the following URL in de SDK of Microsoft:

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.portal.webcontrols.dropdownmodes.aspx

Related Posts

SharePoint Rest API Handler SharePoint contains a lot of Rest API’s that can be used for many scenario’s. You could use them for example in desktop and windows phone applications...
User automatically removed from SharePoint Group During my current project we received an access request from a user. We did what we normally do, we checked the request and added the user in the appr...
Warm Up Form Based Web Application Normal warm up scripts for SharePoint open a site object or web object and make a request to that specific site. When you use form based authenticatio...
Load modules by default when opening PowerShell At the moment we are working a lot with PowerShell in combination with SharePoint. Over time we created a lot of usable functions that were not availi...
PowerShell Scripts During my current project we are using a lot of PowerShell scripts to administrate the environment and make development easier for us. In this post...
TFS and SharePoint Builds including Automatic deployments – Part 1 Part 1 of this series will instruct how to configure your build server for building SharePoint projects. In Part 2 we will discuss the automatic deplo...

Leave a Reply

Your email address will not be published. Required fields are marked *