Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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)

share|improve this answer
    
Very useful information! Thanks Wictor! –  Wim Hill May 30 '11 at 11:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.