In SharePoint 2013, one can create dynamic metadata navigation, using the benefits of both Managed Metadata and Search. The result is dynamic navigation that is built in through a taxonomy that shows the current search results filtered by the current node (with or without children, depending on the current configuration). Figure 1 shows an example.
Figure 1: Sample navigation
1. Navigation has to be dynamic, that is, when one adds a new term to the term store, it has to be displayed on the navigation (and has to work) immediately.
On the target page, search results have to be displayed, filtered by the selected navigation item. (Note: As the results or items are provided by search, they are refreshed by each full or incremental crawl.)
2. A configuration parameter is expected. The parameter defines whether only the exact matches will be displayed, OR whether the matches for the children of the selected navigation item will also be included. (For example, when one selects "Germany" above, the configuration parameter determines whether the values for "Berlin", "Frankfurt" and "Munich" will also be displayed.)
Steps to achieve this behavior in SharePoint 2013
- Preparation (creating a site and a target page)
- Configuration of Managed metadata (Term Set)
- Configuration of Search
- Configuration of Site navigation settings
- Insertion and customization of Content Search web part
Preparation: Create a page that will be the target page later. You will need to reference this page in the following steps:
- Create a site where you want to use the metadata navigation. For example, \catalog.
- Create a target page, where you'll add the appropriate ContentSearch web part later. Leave it empty for now.
- Save the page with a name like /catalog/SitePages/Home.aspx
Term Set: As always, you need to create TermSet, but with some special settings in this case.
- On the tab, "Intended Use," you need to enable the following checkboxes:
- "Available for Tagging"
- "Use this Term Set for Site Navigation"
- Term Driven Pages: Enter the path of the page you created in the previous step--e.g., /catalog/SitePages/Home.aspx--or select with the Browse button
- Create the appropriate content source or sources
- Make sure you have created a ManagedProperty for your Managed Metadata, with the settings: Queryable, Retrievable, and Refinable enabled. Note its name; in my demo the name is DemoLocation.
- Run a Full Crawl
Next, you have to edit the site's settings created in the first step (/catalog) in order to enable Metadata Navigation. In my example it's enabled for the Top Navigation, but you can enable it for Quick Launch, as well.
- Go to the Site Settings, and open Navigation (which you'll find in the group "Look and Feel").
- For "Global Navigation," select "Managed Navigation," as you can see in Figure 2.
Figure 2: Select Managed Navigation
3. Select the appropriate Term Set, as shown in Figure 3
Figure 3: Select the Term Set
4. Select both check boxes in Managed Navigation: Default Page Settings:
- Add New pages to navigation automatically
- Create friendly URLs for new pages automatically
5. Save your settings
As a result, you should see the Managed Navigation now, without showing any results, of course. The URLs will appear as friendly, like the following: demo2013.aghy.hu/catalog/SitePages/Home.aspx#/europe/germany/berlin
The next and last step here is to add the appropriate ContentSearch Web Part to your target page:
- Edit your page and click on Add New Web Part.
- Select Content Rollup/Content Search Web Part, and click Add.
- In the Select Query dropdown, select the Result Source you want to use.
- In the Property Filter, select your Managed Property (which you created for your Term Set, earlier). If you cannot see your Managed Property, click Show All Managed Properties first. Select Contains and Site navigation Terms of current pages and subpages.
- Click Add property filter.
Save your settings. Now the appropriate search results will be displayed.
Note that by default, the display of results is very ugly here. To create a better look and feel, you can play with the Display Templates. In my demo, I use the following additional settings of the Content Search Web Part:
- Properties/Display Templates/Item: Two lines
- Uncheck the check box that says, Don't show anything when there are no results
- Properties/Property Mappings/Change the mapping of managed properties
- Link URL: Path
- Line 1: Title
- Line 2: Path
Of course, you can achieve some advanced formatting, creating your custom Display Template the Item.