This post is a continuation of my previous blog post explaining advanced content targeting using SharePoint search. We saw earlier how to implement a custom token for the logged in user which filters incoming content in the search index based on the user’s profile attributes. Today we are going to look into creating display templates to render custom result URLs. Before we begin let’s refresh our memory with the scenario here
An internal portal accessed by employees and contractors in three dozen locations comprising of countries and/or regions. Authoring takes place in a separate content site and content is rendered on the publishing site. All content is targeted with three important profile attributes –
a. Location (comprises of country and their region)
c. Business Unit
Each piece of content/link takes the user to the publishing site keeping authoring unexposed to the end user. What this means for search results is
1. The results should be targeted based on user profile properties (mentioned above)
2. Customizing search results URL to point to publishing site
3. Customizing hover preview to display publishing pages (instead of the authoring site content pages)
4. Customizing Control template to implement custom paging
The IT Leader's Guide to Multicloud Readiness
This guide provides practical key insights and important factors to consider to make informed decisions in your multicloud journey.
In the previous post we covered #1 above. This post will focus on #2.
By default all the search results points the user to the actual authoring pages which is (in this case) sitting in a separate site. Because the authoring site (usually) does not have any branding or targeting enabled, we do not want our users to lose their place in the navigation. In order to avoid that we came up with top level category pages with each of them having sub category sections which render page content from the authoring site. So in essence the publishing site URL for any piece of content will look like this: http://inranetportal.com/pages/[categoryname].aspx#[subcategory]. The hash tag in the URL is to enable anchor links (bookmark) feature. It’s not relevant in this context so we’ll leave it out.
1. We declare the managed property mappings – Here we used RefinableString0 and RefinableString1 to map the category and sub category metadata fields.
2. Build a custom linkURL
3. This leads us to the html section to render the linkURL
4. And this is how the result URL look like