Changing the SmallSearchInputBox delegate control

A colleague of mine was wanting to make some changes to the SmallSearchInputBox delegate control in SharePoint 2007. That’s the control that appears on most pages, looking like:

SmallSearchInputBox

This control is a ‘Delegate control’ – that is, you can create features to override the currently used control. What my colleague wanted to do was not display the ‘Scope’ drop down list, the Advanced Search link, and to include prompt text (something like ‘Enter Search…’). A quick dig into the FEATURES folder in 12 Hive showed that the control had a number of properties.

(The features that this information applies to are the OSearchBasicFeature and OSearchEnhancedFeature. Both contain files called ‘SearchArea.xml’, and that contains the code below. I found the folders with this in:

%12 Hive%\Template\Features\OSearchBasicFeature

%12 Hive%\Template\Features\OSearchEnhancedFeature )

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Control
Id="SmallSearchInputBox"
Sequence="25"
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>
</Control>
</Elements>

This shows a property ShowAdvancedSearch which sounded pretty promising for turning off the Advanced Search link. We decided to see what other properties were available, and found a good article by Clint Cherry about the SmallSearchInputBox control, and the MSDN docs. The Property tags in the XML for the delegate control set the properties of the web control class – e.g. GoImageUrl matches the GoImageUrl property on the class. Much to our pleasure, we found the QueryPromptString displays text in the search control which vanishes when it receives focus, and the DropDownMode property allows us to turn off the scope dropdown list. Hurrah!

For the values that you can set the drop down mode to, see the MSDN docs again

7 thoughts on “Changing the SmallSearchInputBox delegate control

  1. Hi, This is a good article and better is the Clint Cherry’s one. But, I want to modify the search control in a WSS installation. The feature is different or I don’t know how to search it on FEATURES folder. Could you show me how it can be done on WSS???

    Thanks in advance.

  2. Just a note for dudes using WSS…

    As far as i can see this does not work for WSS 3. The file I found in the 12-folder is called “Feature.xml” …. loacted in “…..\12\TEMPLATE\FEATURES\SPSearchFeature”.

    In the folder “…..\12\TEMPLATE\CONTROLTEMPLATES” theres a file called “SearchArea.ascx”… but that’s a ASP.NET file (or whatever) not XML. I could edit this file, but that would be even more crappy then WSS itself. Or I could style the search-field using CSS, but the control has a lot of useless HTML that I would like to get rid of… Like “display=inline” – get real Microsoft thats CSS not HTML

    From the SearchArea.ascx:
    < INPUT Type=TEXT id=’idSearchString’ size=25 name=’SearchString’ display=’inline’ maxlength=255 ACCESSKEY=S class=’ms-searchbox’ …

  3. Hmm, yes my article misses some information.

    The features that this information applies to are the OSearchBasicFeature and OSearchEnhancedFeature. Both contain files called ‘SearchArea.xml’, and that contains the code above.

    I don’t know if this is the same in WSS – but if you can’t find folders called:
    % 12 Hive%\Template\Features\OSearchBasicFeature or
    % 12 Hive%\Template\Features\OSearchEnhancedFeature

    …then I’d suggest that this doesn’t apply. In fact, given that WSS and MOSS have quite different search functionality, I’d suggest that this is likely to be the case.

    And yes, the CONTROLTEMPLATES directory contains ASPX controls. And yes, they’re not always the best written.

  4. Hi,
    I dont know whether am running sharepoint 2007 or wss 3.0 . I think wss 3.0. How to find it.
    This works well with me, just have to change property to false of false
    as you described
    Regards,
    Suresh kumar V.C

  5. I confirm, this does not apply to WSS 3.0. These features described here are not part of the WSS 3.0 search.

  6. Great article. I updated the xml files and saved them but the changes aren’t reflected on the page until I perform an iisreset. I assume it’s SP caching the control, you might want to mention an iisreset is required.

  7. Yup, that’d be correct – sorry, I didn’t mention that ‘cos I’m sort of used to having to do an IIS reset after, well, just about everything in Sharepoint 2007!

Comments are closed.