SharePoint 2013 Search - Item Display template - Get Document Library URL for the item

We are creating custom display templates for SP2013 search results and as part of the template need to get the URL of document library containing the item in the search item display template.

Initially thought, this was easy however have spent a considerable amount of time without much success. The problem is that the documents returned by search might reside in folders (can be multiple levels) or can be document sets within the document library. However, I just need the URL until the document library.

So far have tried multiple managed properties (ParentLink, Path, OriginalPath, SitePath etc.) that might give me just that path but no luck.

Anyone knows how to acccess this or there is a work around? Note: This is SP2013 on-premise.

I know this was done using XSLT in SP2010. See the below link. However not able to convert the same to a SP2013 display template using HTML and JS.

https://social.technet.microsoft.com/Forums/fr-FR/1389d442-500c-4ed5-9ecf-2336ca78c52a/how-to-get-a-link-to-the-documents-properties-in-a-search-results-even-when-the-document-is-in-a?forum=sharepointadminprevious

Basically need to understand the following 2 lines and somehow convert them to be usable in SP2013 item display template:

<xsl:variable

 name="library" select="substring-after(substring-after($low_url,$low_sitepath),'/')" />

<xsl:variable

 name="displayUrl" select="concat($low_sitepath, '/', substring-before($library,'/'),'/Forms/DispForm.aspx?ID=',$listitemid)" />


July 29th, 2015 2:30pm

Are you following similar instructions to create your Search Display Templates as mentioned here http://www.abelsolutions.com/totm/creating-customized-search-results-in-sharepoint-2013/

If so, Have you tried to utilise the code provided by file "Item_Default.html". Because this display template shows the Item Display URL in full utilizing "Item_Default_HoverPanel.html" template.

Free Windows Admin Tool Kit Click here and download it now
July 29th, 2015 10:11pm

Yes I am using a copy of the Item_Default existing template and customizing it taking it forward. The Display URL, I believe you are referring to the View Library link that is available in the hover panel?

I did check the "View in Library" in the hover template. This displays the complete link i.e. including the folders as well, so if I have document library and multiple folders within it. It shows the link until the respective folder in that document library. However I just need the path until the respective document library. Figuring out from the complete URL seems difficult as there can be multiple levels of folders while can also include document sets.

Thanks in advance.


July 30th, 2015 8:42am

Have you solved this issue yet?
Free Windows Admin Tool Kit Click here and download it now
August 10th, 2015 10:07pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics