Thursday, July 2, 2009

Changing SharePoint default search scope

If you have Advanced Search enabled in your SharePoint site, then on your site’s home page Search drop down box, you will see 3 options :
This Site : Your Site Name (This will search only on the current site collection)
All Sites (This will search in everywhere in farm)
People (This is for searching people from AD)

In the drop down the default selected scope is “All Sites”. That means whenever user wants to search something on your site, he has to change value in drop down every time. So it is very obvious to change the default to “This Site : Your Site Name”, because most of the times user wants to search only in your site.

To change this default value, we need to make only one change in following file:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\OSearchEnhancedFeature\ SearchArea.xml

We have to add one PropertyName line at the end of the file (right after line <property name="ShowAdvancedSearch">true</property>)

<property name="DropDownMode">ShowDD_DefaultContextual</property>

That’s it. We are done.
The only thing that most of us wouldn’t like is to modify oob xml file. But I think we can add/remove this line using feature in this file. So that we can overcome all known issues.