SharePoint DelegateControl – SmallSearchInputBox

Normally shown on the home page for a site, there is a “search box” – that a user can enter a keyword and hit enter.  

There is a ‘prompt text’ that shows, and is cleared when the user clicks on the box.

image

How do you CHANGE the text being shown !?

Master Page

Within the Master Page – there is a control that is defined as a “DelegateControl” :

<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
    <SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" Version="4" />
</asp:ContentPlaceHolder>

There are actually no properties that you can set – when viewing in SharePoint Designer – I tried !

DelegateControls

The problem is that the control is ‘abstracted’ rather than being hard-coded into the master page.   You can thus override the control fairly easily – once you know how of course.

This control is actually a SharePoint feature – called OSearchBasicFeature (and there is an OSearchEnhancedFeature).

If you look into the 14 hive, you’ll find the specific details for the control/s.

  • {SharePointRoot}TEMPLATEFEATURESOSearchBasicFeature
  • {SharePointRoot}TEMPLATEFEATURESOSearchEnhancedFeature

There is a file entitled “SearchArea.xml” which contains the details you need :

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="
http://schemas.microsoft.com/sharepoint/">
    <Control
        Id="SmallSearchInputBox"
        Sequence="50"
        ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx" ControlAssembly="Microsoft.Office.Portal, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
    <Property Name="GoImageUrl">/_layouts/images/gosearch15.png</Property>
    <Property Name="GoImageUrlRTL">/_layouts/images/gosearchrtl15.png</Property>
    <Property Name="GoImageActiveUrl">/_layouts/images/gosearchhover15.png</Property>
    <Property Name="GoImageActiveUrlRTL">/_layouts/images/gosearchrtlhover15.png</Property>
    <Property Name="DropDownMode">ShowDD</Property>
        <Property Name="SearchResultPageURL">/_layouts/osssearchresults.aspx</Property>
    <Property Name="ScopeDisplayGroupName"></Property>
    <Property Name="FrameType">None</Property>
    </Control>   
</Elements>
Create your own (to override)

In order to override these attributes – you need to create a SharePoint feature – with the specific elements you need.

  • Open Visual Studio 2010
  • Create a new “Empty SharePoint project” – call it ChangeSearchTitle (for example)
  • Right-click – and select “Add New Item”
  • Choose the “Empty Element” item – call it ChangeSearchTitle

This will be the framework of your ‘feature’ – just need to paste in the details from the “SearchArea.xml”

  • Within the ELEMENTS.XML file, paste the contents (as above)
  • Add a Property after the “FrameType” :

<Property Name="QueryPromptString">DO A SEARCH !!</Property>

Deploy + Test

That’s ALL you need to do – seriously !

  • Deploy the project from Visual Studio – you might like to change the Feature name – and/or Package.
  • Go to your SharePoint site – and activate the feature – if not already

image

And – it looks like this…>

image

Or – for a closer look :

image

Here’s the exact ELEMENTS.XML I’ve used for this example :

<?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=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">
    <Property Name="QueryPromptString">DO A SEARCH !!</Property>
    <Property Name="DropDownMode">HideDD_NoScope</Property>
    <Property Name="SearchResultPageURL">/_layouts/osssearchresults.aspx</Property>
    <Property Name="ScopeDisplayGroupName"></Property>
    <Property Name="FrameType">None</Property>

  </Control>
</Elements>

See here for a list of the “properties” you can include in the ELEMENTS.XML :

NB   If you get any of the properties wrong, the search box simply doesn’t show – I had the DropDownMode as “HideDD” – instead of one of these options.

See more here – relates to MOSS 2007 though (12 hive) – thanks guys !!

Advertisements

4 thoughts on “SharePoint DelegateControl – SmallSearchInputBox

  1. Pingback: Replace SharePoint Delegate Control – SmallSearchInputBox « SharePointRoot

  2. Pingback: SharePoint 2010: Recopilatorio de enlaces interesantes (XX)! « Pasión por la tecnología…

  3. Pingback: SharePoint 2010: Recopilatorio de enlaces interesantes (XX)! - Blog del CIIN

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s