Working with SharePoint is typical we have to do little customizations in Branding, so it is really helpful to understand and know the Out-of-the-box controls or webparts that SharePoint provides. That could be a good time saver to meet our requirements easily.
On this time, the requirement was to have two search controls in the same master page, one to find everything, other to find people.
Before SharePoint 2013, it was used the
SearchBoxEx control, but with the Display Templates engine used in SharePoint 2013, there was included a new control named
You can see good description about these two controls and Display Templates, here
To achieve our goal and put two controls in the same Master Page, we can use this code:
Some important notes inside the code:
- I roughly recommend to use
UseSiteCollectionSettings="true"ONLY in one control. And in the other control use static links inside.
InitialPrompttext avoid to put the text using jQuery :D .
UseSharedSettings="false"will allow you to use custom Display Template and Results Page.
RenderTemplateIdis useful to change completely the aspect, even it is needed to change GO Search icon.
ServerInitialRender="false"will produce JS files and use Display Template engine, otherwise the control is rendered in the Server Side.
- If you want to apply custom
RenderTemplateIdit is MANDATORY to have
DefaultDropdownNodeId="1001"is useful to set the default scope. 1001 – Search Everything, 1002 – Search People, …
- Branding the Search Box in SharePoint 2013: http://www.eliostruyf.com/branding-the-search-box-in-sharepoint-2013/
- SearchBoxScriptWebPart properties: https://msdn.microsoft.com/en-us/library/microsoft.office.server.search.webcontrols.searchboxscriptwebpart_properties.aspx