Below you will find the slide deck and source code for my session “Create Tailored Search Results w/ Display Templates” presented to the Triangle SharePoint User Group on 7/1/2014.
Source Code is available here.
A pretty common request I get when working with Search results for content solutions is to display the results as a grid, and not the normal block format we see with the standard search results below.
For this example, we are going to assume that the grid format will be applied to all items uniformly. To do that, we will select a specific display template to use instead of allowing the rules to detect the appropriate template, item by item. For this example, I’m going to work with a copy of the Item_OfficeDocument.html display template which has the following markup:
The ctx.RenderBody(ctx) line will inject the standard rendered output. You can really structure this with whatever markup suits your requirements. When I need to provide a grid or tabular format I will typically use an unordered list that floats. Here is a simple three column example:
In this example, you may notice that I also did some formatting the UTC formatted date. This is a good example of how we can manipulate the data as needed. Below is an example of the grid view.
While this is a simple example that uses only default fields available to all lists and libraries, it is easy to add in additional properties that can be leveraged by your markup. The only real stipulation here is that you will need to make sure that it is a property recognized by the search index. At the top of the document there is property called "ManagedPropertyMapping" which lists the properties that need to be loaded and available for the markup. Here is the default value for the Item_OfficeDOcument template.
To add in a custom property, you simply need to add in the name/value pair. For example:
One of my main focuses the past 4-5 years has been leveraging the Search Infrastructure to help deliver dynamic content to portals and Intranets. In previous versions of SharePoint I leaned heavily on the underlying APIs to deliver custom solutions. This was both because the underlying APIs allowed more precise querying and because it gave me full control on what was rendered to the user.
I intend for this post to be a bit of a primer on the high level topics. I’ll be coming out with some specific task-driven follow up posts over the next few weeks that expand on these concepts and get into some examples of things that can be done through these new features.
For those that haven’t caught my session Dynamic Content using SharePoint Search here is a brief overview.
The web parts themselves are broken into the following categories:
Within the Content Rollup category resides the Content Search web part. This is a great replacement for the Content Query Web Part (CQWP) available in past versions of SharePoint. Unlike the CQWP, this utilizes the search service so it can pull matching results from anywhere in your farm, which means you are not limited to the current site collection.
The web part also supports new, previously unavailable display options including the ability to show the item as a slideshow.
The Search-Driven Content category contains a series of web parts that are all based on the Content Search web part, with a pre-set query to help you get started. This includes results that display specific types of content like the Videos, Web Pages, Wiki Pages, Pictures, Pages, and then also results that rely on the analytics features to deliver results pertaining to Popular Items, Recently Changed Items, and Recommended Items. The pre-configured queries are a great start, and using the query builder form you can dial in the specific results you are looking to display.
The display templates are stored in the Master Page Gallery for each site collection. You can find them by browsing to Site Settings, and clicking the Master pages and page layouts link under the Web Designer Galleries group. From within the gallery, browse into the display templates directory, and then into the Search directory for search specific display templates.
A good reference for the included display templates is available here on the TechNet/MSDN website: http://technet.microsoft.com/en-us/library/jj944947(v=office.15).aspx
Here is a good overview of how to work with the display templates: http://msdn.microsoft.com/en-us/library/office/jj945138(v=office.15).aspx
Great first event for the crew in New Jersey. Lots of attendees and a high level of interest at the event. Thanks to everyone that attended the developer panel discussion and the my 10 Tips for Managing SharePoint Search sessions. Below is the slide deck for the session.
I think everyone had a fantastic time at the inaugural SharePoint and .NET Saturday Bermuda event. I’m honored to have been able to participate. The hospitality on the island was fantastic, and while the event was small, there was good participation in the sessions. I hope everyone got a lot out of the day.
I’ve uploaded my deck to slide share so it is available below.
I look forward to future events!
SharePoint Saturday Atlanta was a great success again this year with a record turnout that included many eager participants.
Thanks to all of the attendees that attended my sessions. Here is the supporting content.
I’m excited to announce that I have had two sessions selected for the SPS Atlanta event on Saturday June 8th. The past few years the organizers have established this event as one of the premiere events in the south east.
The first session is an End User focused session titled Using Search for Dynamic Content.
This session is geared towards site owners and power users and will provide an overview of the search web parts available out of the box in SharePoint 2010 and 2013 and show how they can be used to display dynamic, search driven content on your sites. We will also do an overview of the Keyword Query Language allowing you to leverage the features to display dynamic content on your sites.
The second session is a Developer focused session titled Introduction to SharePoint’s Social APIs
SharePoint 2010 and 2013 offers a rich set of social capabilities that are built into the platform. Those capabilities are available to developers through a variety of APIs so that they can be extended or leveraged in your other customizations and applications. This session will run through the various client, server, and REST APIs available to developers.
Hope to see a full house!