Project to customize the small search control in SharePoint 2007
<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="http://schemas.microsoft.com/sharepoint/"> <Control Id="SmallSearchInputBox" Sequence="50" ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx"
ControlAssembly="Microsoft.SharePoint.Portal, Version=22.214.171.124, 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:
- 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.
- Copy/Paste "OSearchBasicFeature" in the same feature folder with a different name (like mySimpleSearch).
- Change the feature ID in the feature.xml file within mySimplerSearch feature.
- Change the control ID in the SearchArea.xml file to something like "mySimleSearchcontrol".
- 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.
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!!!