共用方式為


Hiding Search Scopes Dropdown in Site Master Page

When I was looking to implement this for one of the SharePoint sites I worked on, I never was able to find a step by step instructions. Here is exact steps to hide scopes drop down in site master page

Under your Features folder look for "OSearchBasicFeature" folder and copy and rename this to say for ex "SearchBasicFeatureWithOutContextualScope"

Edit the feature.xml file and replace the id and title, you can generate a new id by using the Generate GUID tool in Visual Studio. Here is what my customized feature file looks like

<?xml version="1.0" encoding="utf-8" ?>

<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->

<Feature  Id="601D5F49-A45E-4c58-B14B-829AB593C4BC"

          Title="SearchBox with no contextual scope"

          Description="$Resources:BasicSearch_Feature_Description;"

          DefaultResourceFile="spscore"

          Version="12.0.0.0"

          Scope="WebApplication"

          ReceiverAssembly="Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

          ReceiverClass="Microsoft.Office.Server.Search.Administration.BasicSearchFeatureReceiver"

          xmlns="https://schemas.microsoft.com/sharepoint/">

    <ElementManifests>

        <ElementManifest Location="searcharea.xml"/>

    </ElementManifests>

</Feature>

Next up open the SearchArea.xml file in Visual Studio and change the dropdownmode property to "HideDD_useDefaultScope", Here is what my customized searcharea.xml looks like

<?xml version="1.0" encoding="utf-8" ?>

<Elements xmlns="https://schemas.microsoft.com/sharepoint/">

    <Control

        Id="SmallSearchInputBoxWithOutContextualScope"

        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/twg/goRTL.gif</Property>

      <Property Name="GoImageActiveUrl">/_layouts/images/gosearch.gif</Property>

      <Property Name="GoImageActiveUrlRTL">/_layouts/images/goRTL.gif</Property>

      <Property Name="DropDownMode">HideDD_useDefaultScope</Property>

      <Property Name="SearchResultPageURL">/_layouts/osssearchresults.aspx</Property>

      <Property Name="ScopeDisplayGroupName"></Property>

      <Property Name="FrameType">None</Property>

      <Property Name="ShowAdvancedSearch">false</Property>

    </Control>

</Elements>

 

Install the feature.

Stsadm –o installfeature –filename SearchBasicFeatureWithOutContextualScope\Feature.xml

Activate the feature for web application

Stsadm –o activatefeature –filename SearchBasicFeatureWithContextualScope\Feature.xml –url {your web application url}

In your master page look for content place holder PlaceHolderSearchArea and change the ControlID attribute of SharePoint Delegate control to “SmallSearchInputBoxWithOutContextualScope”

Here is an example markup from my master page

<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">

         <!--SmallSearchInputBox -->

         <SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBoxWithOutContextualScope" />

</asp:ContentPlaceHolder>

Comments

  • Anonymous
    June 26, 2008
    PingBack from http://stevepietrek.com/2008/06/26/links-6262008/

  • Anonymous
    August 28, 2009
    Can't we directly set the property in the master page as "DropDownMode = "HideDD_useDefaultScope" ?

  • Anonymous
    September 23, 2009
    or just set the CSS... .ms-sbcopes {     display:none; }

  • Anonymous
    April 02, 2010
    I tried the above to override some different properties, namely SearchResultPageURL which I was unable get to work.  It was like that was the only property that didn't work -- your example uses the default url so you would not have noticed.