Project to customize the small search control in SharePoint 2007

The small search control that is rendered in the default SharePoint pages is a delegate control rendered through master page. You can find it defined in the master page as follows: image

 <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.  Do not modify any out of the box files as they might lead you into an unsupported scenario.  Instead, following are the simple steps to get the small search control customized:

  1. Create a custom master page by copying the default.master page.  I haven't tested with minimal master as explained here but I am guessing that would work either.
  2. Copy/Paste "OSearchBasicFeature" in the same feature folder with a different name (like mySimpleSearch).
  3. Change the feature ID in the feature.xml file within mySimplerSearch feature.
  4. Change the control ID in the SearchArea.xml file to something like "mySimleSearchcontrol".
  5. Change the class & assembly referenced in the SearchArea.xml file to the control library you created above.
  6. Install & Activate this feature,
  7. Render the custom control you created in the custom master page have and remove "SmallSearchInputBox" control from the master page.

This should do the tricky and you should be able to literally customizing anything within the small search control.

Happy customizing your SharePoint environment - and I really hope this post was helpful!  Look around for things like this in SharePoint as there are plenty of "hacks" to get things done!!!