Search panels in MacroView DMF and Message by default return results from all site collections on the selected SharePoint server or Office 365 (SharePoint Online) tenant. When you need to limit the results to just one or two site collections there are a number of options.
- Right-click on the site collection in Browse mode and select Search this location which will restrict the scope of any selected search panel to just that site collection.
- Add a WHERE clause in the definition of the search panel to restrict the results to items with a specific URL path stem whenever that search panel is used.
- Add a drop-down control to the search panel with choices corresponding to the site collections (or sites) the search results are to be restricted to. Below are the step to add such a control to your search panel.
Adding the drop-down control
In your search panel XML file, add the drop-down control by entering the following code into the <Controls> section.
<Control Name="Path" Type="Dropdown" DisplayName="Locations" >
<Item DisplayName="Sales" Value="https://tenant.sharepoint.com/sites/sales/*"/>
<Item DisplayName="Matters" Value="https://tenant.sharepoint.com/sites/matters/*"/>
<Item DisplayName="Sales and Matters" Value="https://tenant.sharepoint.com/sites/sales/*;https://tenant.sharepoint.com/sites/matters/*"/>
<Item DisplayName="All Sites" Value=""/>
</Control>
Then:
- Leave the Name as "Path" as this links the control to the URL (path) of the search results.
- Change the DisplayName value in the first line to the label you want displayed for each site collection.
- Change the DisplayName value for each 'Item' to the values to show in the drop-down control.
- Change the path in the Value parameter for each 'Item' to the path of the site collection the results are to be restricted to when this option is selected. Always leave the '*' at the end of path.
- To restrict an 'Item' to multiple site collections, enter each site collection url in the Value parameter separated by a semi-colon (Sales and Matters example above).
- To include an option to return results for all site collections, set the Value parameter to ""
The example control definition above would display as shown below and would restrict the search results to items for those sites collections that match the selected option.
.