Customizing Small Search Box
Small Search control which is rendered in default pages of Sharepoint is a delegate control which is rendered through Default.Master available under C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL (assuming C drive is the installation drive for MOSS)
Entry in Default.Master Page
<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
<SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" />
</asp:ContentPlaceHolder>
This control is actually available through a feature called "OSearchBasicFeature" located under 12\TEMPLATE\FEATURES. In the feature elements file (in this feature it's called "SearchArea.xml"), you can see the following:
<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
<Control
Id="SmallSearchInputBox"
Sequence="50"
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="DropDownMode">ShowDD</Property>
<Property Name="SearchResultPageURL">/_layouts/osssearchresults.aspx</Property>
<Property Name="ScopeDisplayGroupName"></Property>
<Property Name="FrameType">None</Property>
</Control>
</Elements>
The main class here seems to be Microsoft.SharePoint.Portal.WebControls.SearchBoxEx. To customize small search, you need to inherit from "SearchBoxEx" class and override "CreateChildControls" method to get your custom small search rendered
If you would like to customize this Delegate control (within support boundries ) there are 2 ways.
Method 1
· Create a custom master page by copying the default.master page
· Copy/Paste "OSearchBasicFeature" in the same feature folder with a different name (like CustomSimpleSearch).
· Change the feature ID in the feature.xml file within CustomSimpleSearch feature
· Change the control ID in the SearchArea.xml file to something like "myCustomSearchcontrol".
· Change the class & assembly referenced in the SearchArea.xml file to the control library you created above.
· Install & Activate this feature
· Render the custom control you created in the custom master page have and remove "SmallSearchInputBox" control from the master page
Method 2
Microsoft.SharePoint.PortalWebControls.SearchBoxEx class and you don't need to create a new control.
There are a large number of properties you can use to customize the control and you should find the one you're looking for microsoft.sharepoint.portal.webcontrols.searchboxex_properties.
· Create a new Feature (DelegateControl) under “C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES”
· Create a new manifest.xml in DelegateControl feature folder
<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="https://www.w3.org/2001/XMLSchema"
SolutionId="GENERATE_A_GUID"
ResetWebServer="True"
xmlns="https://schemas.microsoft.com/sharepoint/">
<FeatureManifests>
<FeatureManifest Location="PortalSearch\feature.xml" />
</FeatureManifests>
</Solution>
· Create a new feature.xml in DelegateControl feature folder
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="7095f774-1efa-4879-b074-ff211f5559c7"
Title="Small Portal Search"
Description="Smaller search bar without scopes"
Version="12.0.0.0"
Hidden="FALSE"
Scope="Web"
DefaultResourceFile="core" xmlns="https://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="elements.xml"/>
</ElementManifests>
</Feature>
· Create a new elements.xml in DelegateControl feature folder
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
<Control
Id="SmallSearchInputBox"
Sequence="23"
ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx"
ControlAssembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
<Property Name="SearchResultPageURL">/search/results.aspx</Property>
<Property Name="FrameType">None</Property>
<Property Name="DropDownMode">HideDD_NoScope</Property>
<Property Name="TextBoxWidth">140</Property>
<Property Name="ShowAdvancedSearch">false</Property>
</Control>
</Elements>
Install and activate the feature. Scope of this sample feature is Site level. You can modify it to reflect any scope.
The parameters I'm using set the "SearchResultPageURL", hide the scope drop down and remove the advance search link.
Comments
Anonymous
March 23, 2009
This blog has been created to share useful information. Thanks and greetings!Anonymous
August 10, 2009
Hi Pavan, thanks for the great resource on search customization. I was trying to follow method 2 and unable to understand the step one, creating new feature could you please eloborate with the steps as to how do i create feature there. and the steps involved in this. much appriciate your help. thanks.