次の方法で共有


Search features, web parts and delegate controls

SharePoint has got great power with it's delagate controls. With the default.master the following delegate controls are available:

  • AdditionalPageHead
  • GlobalSiteLink0
  • GlobalSiteLink1
  • GlobalSiteLink2
  • SmallSearchInputBox
  • TopNavigationDataSource
  • PublishingConsole
  • QuickLaunchDataSource

Delegate lets you change the the control during run time. So you can apply the best control possible, for just one site and not another.

After having read a few of the online guides on how to use delegates, I would like to point out that they are not limited to web and site scopes. They work great on web application level as well. Implemented wisely this can save you an extra set of master pages...!

 

Here are some of the guides:

https://msdn2.microsoft.com/en-us/library/ms463169.aspx

https://www.sharepointbuzz.com/index.php/2008/01/16/how-to-change-search-box-image/

https://www.sharepointblogs.com/mrbill/archive/2007/05/24/using-delegate-controls-in-sharepoint.aspx

https://www.devx.com/enterprise/Article/36628/1954?pf=true

 

Small example:

I wanted a search box without a dropdown on my portal, but with a dropdown on the team sites. So I implemented two set of features:

Nr.1

Searcharea.xml

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="https://schemas.microsoft.com/sharepoint/">
  <Control
Id="SmallSearchInputBox"
Sequence="12"
ControlClass="Microsoft.SharePoint.Portal.WebControls.SearchBoxEx" ControlAssembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">

    <Property Name="GoImageUrl">/_layouts/images/SearchButton.jpg</Property>
    <Property Name="GoImageUrlRTL">/_layouts/images/SearchButton.jpg</Property>
    <Property Name="GoImageActiveUrl">/_layouts/images/SearchButton.jpg</Property>
    <Property Name="GoImageActiveUrlRTL">/_layouts/images/SearchButton.jpg</Property>
    <Property Name="UseSiteDefaults">false</Property>
    <Property Name="FrameType">None</Property>
    <Property Name="DropDownMode">HideScopeDD</Property>
    <Property Name="DropDownWidth">140</Property>
    <Property Name="ShowAdvancedSearch">false</Property>
    <Property Name="SearchResultPageURL">https://contoso.com/search/pages/results.aspx</Property>
  </Control>
</Elements>

 

Feature.xml
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Feature Id="......"
Title="Search box feature for the Portal header"
Description="Search feature - replaces OOB feature"
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>

 

Nr.2

I created two similiar files, but exchanged

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

with

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

 

Installed the featueres, open central admin and enabled one feature for each web application. Easy? :)

Have you used delegates in a cool way? Drop me a line!

Comments