How to create a Custom Search Results page in SharePoint

There are times when you feel the need to have a custom search results page especially when you want to include extra fields from list/document libraries in your search results which are not included by default. Search results with custom look and feel can be the other possible reason.

Sharepoint provides many Out-of-the-box search webparts. To create a custom search results page, you just need to add below listed webparts. Look for these webparts under ‘Search’ category.

Refinement panel webpart
Search Core Results Webpart
Search Statistics webpart
Search paging webpart

Simply place and align these webparts as shown in this image(click it to see the larger version).

Except the Search Core Results webpart, other 3 webparts can be simply added to the page and doesn’t even need any configuration. However, to make the Search Core Results webpart display results with a custom look & feel, there are some configuration steps to be followed.

Steps to Configure Search Core Results webpart

1) Add the ‘Search Core Results’ webpart from the ‘Search’ category in the page.

2) SharePoint Search returns search results in the xml format. Search Core Results webpart use XSL that translates this xml into html elements. To see the search results xml, you can use this xsl. Simply paste this xsl in ‘XSL Editor’ of search core results webpart. ‘XSL editor’ can be found under ‘Display Properties’ tab in the editor part. Please note to enable the ‘XSL editor’ link, uncheck the ‘Use Location Visualization’ checkbox.

3) To change the appearance of search results, you need to provide custom xsl to Search Core Results webpart.  For-example, to make the search results look something similar to shown in the above screenshot, you can use CustomSearchResultsXsl. Simply copy and paste this xsl in ‘XSL editor’ as shown in step 2 and Save.

 

 A Tip to generate custom xsl
The best way to get the custom xsl is to use DataView webpart. Add Dataview webpart using sharepoint designer and set the XML generated in step 2 above as its datasource. Use SP designer’s design view to change the look. This will generate xsl which dataview webpart use to render html. Open the page (with Dataview webpart) in browser, edit webpart and copy the xsl. And, use this xsl in ‘Search Core Results’ webpart.

 

Leave a Comment

Your email address will not be published. Required fields are marked *