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.
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)" />