A client recently asked how to make "This Site" the default SharePoint search scope from the simple search box on all pages. "This site" does not appear as an option when you try to manage this via the GUI (Site Actions | Site Settings | Site Collection Administration section / Search Scopes), so you can't set it as the default there.
I found the answer on this thread on SharePoint Blogs / SharePoint University:
http://www.sharepointblogs.com/forums/t/16293.aspx?PageIndex=2
and I wanted to reproduce it here with a few additions. User Monty Myers (monty.myers) posted the following; my additions are in red:
Add or Modify the following line in the OSearchEnhancedFeature.xml file located in 12\Template\Features\ : (The full path is C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\OSearchEnhancedFeature, then open the SearchArea.xml file in NotePad)
This is the line of code you will add:
<Property Name="DropDownMode">ShowDD_DefaultContextual</Property>
The bold line below shows where the line of code needs to be added:
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control
Id="SmallSearchInputBox"
Sequence="15"
ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx" ControlAssembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<Property Name="GoImageUrl">/_layouts/images/gosearch.gif</Property>
<Property Name="GoImageUrlRTL">/_layouts/images/goRTL.gif</Property>
<Property Name="GoImageActiveUrl">/_layouts/images/gosearch.gif</Property>
<Property Name="GoImageActiveUrlRTL">/_layouts/images/goRTL.gif</Property>
<Property Name="UseSiteDefaults">true</Property>
<Property Name="FrameType">None</Property>
<Property Name="ShowAdvancedSearch">true</Property>
<Property Name="DropDownMode">ShowDD_DefaultContextual</Property>
</Control>
</Elements>
After making the change, save the file and do an IISreset.
Important: when you customize the SearchArea.xml file, it is unghosted, meaning that future patches and upgrades could overwrite your changes. As a best practice, you should create a feature to install this unghosted file to current site collections and deploy the change in this manner.
this works except if the template is a team site or documnet center, then it doesnt
Posted by: Deborah French | April 07, 2011 at 02:22 PM
I found an easier, although quirky way to accomplish this.
1. Create an empty scope within your site collection with any name (I called mine "Dummy Scope"). Make sure the scope has no rules defined.
2. Set the newly created scope to the default scope for the "Search Dropdown" display group.
Apparently, because this search scope is undefined (has no rules) SharePoint will then default to the "This Site: ..." group.
Simple, yet effective.
Posted by: Demondhatter | June 19, 2012 at 12:31 PM
@Demondhatter, thank you very much for posting this information! Yet another of the ways we can trick SharePoint into doing what we want it to do.
Posted by: sadalit | June 19, 2012 at 12:49 PM