Skip to content

How to add “View Library” link to the SharePoint Search results from file share

July 15, 2016

Recently a customer asked me to improve one little thing.
You know the “view library” link that appears once you search for the files in SharePoint?

These guys had setup a search over a file share, but the library link did not appear there.
Apparently the solution appeared to be rather simple. However, I did not find anything in the internet and the customer did not as well.
I assume you are familiar with the display templates concept in the SharePoint 2013. There templates are used to display search results and actually they are JavaScript files (or, in the case of SharePoint Standard, HTML files that generate the JS files).

So the links are rendered by the Item_CommonHoverPanel_Actions.html
This part renders the “View Library” link.

if(!Srch.U.e(ctx.CurrentItem.ParentLink) && ctx.CurrentItem.csr_ShowViewLibrary) {


While debugging I have found out that the CurrentItem.ParentLink is not filled.
I could not find out why it happens that way for the file shares, however, once I found this, the fix became very simple. I have added this simple piece of code before the block.

//ignia custom code
var url = ctx.CurrentItem.csr_Path;
if (url.indexOf('file://') >=0)
var lastIndexOfSlash = url.lastIndexOf('/');
if (lastIndexOfSlash > 0)
ctx.CurrentItem.ParentLink = url.substring(0,lastIndexOfSlash);



From → Sharepoint

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: