In SharePoint 2013, we can use Search Center site to show/display SharePoint search results.
Each search result has 3 parts -
Each search result has 3 parts -
- Heading (which acts as URL/link)
- Description
- Actual URL
We can click on the heading which is actually a hyperlink to go to the search result destination. By default, the search result is opened in same window if we click on hyperlink. If you would like to open the search result in a new window, then it can be achieved by customizing the search results display template. Here are the steps for same -
- Go to Site Settings (You should have Site Collection Administrator permission).
- Go to section Web Designer Galleries.
- Click on Master pages and page layouts.
- A document library will open. Go to folder Display Templates --> Search
- Find following file in the folder - Item_CommonItem_Body.html
- Check-out the file and edit in any text editor.
- Find following line of text -
var titleHtml = String.format('<a clicktype="{0}" id="{1}" href="{2}" class="ms-srch-item-link" title="{3}" onfocus="{4}" {5} {6}</a>',
Add target="_blank" between {5} and {6}. After modification, it will look like this
var titleHtml = String.format('<a clicktype="{0}" id="{1}" href="{2}" class="ms-srch-item-link" title="{3}" onfocus="{4}" {5} target="_blank">{6}</a>',
- Save the file and upload it back to same location from where it was downloaded.
- Check-in and Publish the file.
- Make sure to publish as a major version. In the past, we have faced problem in this template getting applied to other users without major version being published.
Perform a search on the search center site and click on any of the search results. The hyperlinks will now open in new tab/window.
Hope this helps !!!
No comments:
Post a Comment