Application Modernization Industry Quick Guides
Application modernization enables you to optimize business processes and transform the way you do business today, and in the future. Our industry experts have collected the latest application modernization trends impacting the automotive, financial services, healthcare, and manufacturing verticals.
If you have ever worked with customizing search results in SharePoint you will be familiar with the need to write XSLT. I was always somewhat of a reluctant XSLT developer, I was able to achieve some interesting customizations but they did not come without some pain and the feeling that there must be a better way to do this. Well, in 2013 I think we have something better.
We have new concepts for how we put more relevant, targeted or even better formatted results in front of the user. One of these is the concept of a Query Rule.
A Query Rule is executed on a result set when a Query Condition is met. In the example (below) we create a Query Rule to show the user ‘Skydiving Documents’ i.e. documents about the subject of Skydiving (A hobby of mine, please forgive the indulgence!). The condition specifies that when the user searches ‘Skydiving’ we first show the user some Skydiving documents before showing them other results like sites, list items, images etc. Our motivation might be that we want to promote educational documents relating to Skydiving before we show them the dangerous pictures!
The Query Rule Definition:
To build the Action element of the Query Rule our friend the Query Builder helps us out:
So the Action specifies that we should show the user PDF or Word documents with the Title equal to: Skydiving, Jumping, Parachutes or Airplanes i.e. documents relating to Skydiving.
Here is what the results look like when the Query Rule runs:
The Query Rule also has the concept of a Publishing time window in which the Query Rule is active. For example, an eCommerce site might want to promote Halloween related results but only during the month of October. The administrator could set the rule to be active from 1st – 31st October.
Another cool new way to transform search results is to use Result Types and Display Templates. Result Types can be used to identify a specific result e.g. I created a Result Type called Skydiving which matches items with a Title equal to ‘Skydiving’. When the Result Type is matched we can display a specific Display Template to customize how the result appears. My results look like this:
Each item with a Title matching ‘Skydiving’ gets a nice picture of a skydiver inserted just before the result. I have achieved this by creating a Display Template called Item_Skydiving which involved copying an existing HTML Item template, making a small change and uploading as a new template to the Display Template gallery. I won’t go into full code detail on this but to give you an impression of the change here is an excerpt of the HTML template file:
You can see where I have inserted an IMG tag just before the main item. If I wanted to make further changes to the item display I could use the ctx.CurrentItem object to display the result properties and apply some custom formatting.
In my opinion search result customization has become a lot more convenient in 2013 and the elements of it will be more re-usable between result pages.
SharePoint 2013 Search Series:
SharePoint 2013 Search Part 1 – What happened to FAST?
SharePoint 2013 Search Part 2 – Richer Query Language
SharePoint 2013 Search Part 3 – User Experience and WebParts
SharePoint 2013 Search Part 4 – Search Result Customization
SharePoint 2013 Search Part 5 – Search-based Solutions