I would like to use code behind to set the search settings of my site:
- The Site Collection Search Center Url
- Site Collection Search Dropdown Mode: Show Scopes Dropdown
Any ideas on how to implement this?
This is done by modifying properties on the Root Web property bag. Here's a PowerShell sample that I've used to set the same settings on all site collections:
$url = "http://rockingsharepointserver"
Get-SPSite -Limit ALL | foreach{
IF($_.RootWeb.AllProperties -ne $null) {
$_.RootWeb.AllProperties["SRCH_SITE_DROPDOWN_MODE"] = "ShowDD"
$_.RootWeb.AllProperties["SRCH_ENH_FTR_URL"] = "$url/sites/Search/Pages"
$_.RootWeb.Update()
Write-Host -ForeGroundColor blue Updated Search settings for $_.RootWeb.Url
}
$_.RootWeb.Dispose()
}
The easiest way to find out what values you should be using is to configure one site collection and then use SharePoint Designer to inspect the properties (Ribbon > Manage > Site Options)