0

Need some help around the search control as it relates to a publishing site using SP 2010. Right now we have a site that is using this control in the Master.

the issues I am having are as follows. I want to replace the "Search This Site" text with "Search All Sites" I also want to set it up so the scope is searching across the site collection. Would i have to modify the search control directly in the SP Designer? I would rather not have to deploy a custom control.

Any help appreciated.

1
  • Here is the control we are using <asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server"> <SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" Version="4"/> </asp:ContentPlaceHolder> Commented Apr 5, 2011 at 19:30

2 Answers 2

1

That implies that your search box is actually being provided by a delegate control. This is a good thing - it means you don't need to change your master page.

Instead, you need to create a new Feature which contains a delegate control. This is a reasonable description. It's for 2007, but 2010 isn't very different.

When active, your Feature's delegated control is put into the 'DelegateControl' on your page. Now, what control do you want to place in?

Well, the Small Search box is actually provided in a few different forms by different Features. This article describes creating the control for a new one. Again, it's 2007, but 2010 is pretty much the same. Also, this is a good example.

Note that you will need a lower Sequence attribute than the existing search box.

So, in short, you can do all of this without deploying a new control - rather, you're using the existing ones. You do have to create a new Feature, but you only have to write XML. There's no C# involved.

Regarding getting a particular scope - I would acheive this creating a search center within my site collection, and then on the core results web part setting the scope that I want to apply to the results shown. There's an example of this here. Alternatively, you could append the scope to the search query.

0

Actually if you're customising or building your site using SharePoint Designer than creating a new feature is a much bigger issue than modifying the master page (or creating a new master page from the original).

It is possible to replace the delegate control in the master page but there are a couple of things that might bite. I found the publishing infrastructure was replacing the search control in my custom master page with its own control. The work around for me was to replace the delegate control with the SearchBoxEx control via:

  1. Add following to top of the custom master file to register the assembly:

    <%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

  2. Replace <asp:ContentPlaceHolder id="PlaceHolderSearchArea" /> element with the following (which hides the place holder and displays the search box in the same location):

    <asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server" Visible="false"> </asp:ContentPlaceHolder>
    <SharePointWebControls:SearchBoxEx ID="SmallSearchBox" runat="server" ShowAdvancedSearch="false" QueryPromptString="Search…" AppQueryTerms="Scope:MyScope" DropDownMode="HideDD_NoScope" SearchResultPageURL="/sites/MySite/SitePages/osssearchresults.aspx" ScopeDisplayGroupName="" FrameType="None" DisplaySubmittedSearch="false" __WebPartId="{D1535E64-BF7A-4CF5-9B47-A8D44422DC1A}" WebPart="true"/>

  3. If you don't want to use the default search results page take a copy of the OSSSearchResults.aspx page from the 14 hive c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS and put into your sites SitePages folder (to match the SearchResultPageURL property in step 2 above.

  4. Update the OSSSearchResults.aspx to use your custom master page.

  5. At this point the search results page might throw an error because the results page contains a control that is not marked as safe:

    The base type 'Microsoft.Office.Server.Search.Internal.UI.OssSearchResults' is not allowed for this page. The type is not registered as safe.

  6. The resolution to this is to modify the <SafeControls> element in the site's Web.config to include the following element:

    <SafeControl Assembly="Microsoft.Office.Server.Search, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.Office.Server.Search.Internal.UI" TypeName="*" />

  7. And still in Web.config, add a new element to <PageParserPaths> to match the location of your new search page:

    <PageParserPath VirtualPath="/sites/MySite/SitePages/osssearchresults.aspx" CompilationMode="Always" AllowServerSideScript="true" />

  8. That should be sufficient. Remember there is also a search box on the osssearchresults.aspx page that should also be updated to include the SearchBoxEx as in step 2. In my case I also needed to set the search scope as well which is handled by the attribute AppQueryTerms="Scope:MyScope" in the SearchBoxEx declaration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.