Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have exported a content query web part which is looking at a document library. The items appear correctly. The web part was exported to generate a custom appearance. When clicking on the document title, I want it to link directly to the document to download. The below does not seem to be working.

<xsl:template name="document-items">     
    <a href="{@FileRef}">
       <span class="item-title"><xsl:value-of select="@FileLeafRef"/></span>
    </a>
 </xsl:template>

or..

<xsl:template name="document-items">     
<a href="{substring-before(@FileRef, ', ')}">
   <span class="item-title"><xsl:value-of select="@FileLeafRef"/></span>
</a>

share|improve this question

2 Answers 2

Resolved. After fiddling around, I noticed the @FileRef was producing an additional extension of the URL onto the original. Therefore I added the following code:

 <a href="www.yoururlhere.com/{@FileRef}>
<xsl:value-of select="@FileLeafRef"/>

share|improve this answer

Here is another way to do it. With icon and document without the extension.

  <xsl:template name="DocLib" match="Row[@Style='DocLib']" mode="itemstyle">
<xsl:variable name="SafeLinkUrl"><xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="LinkTarget">
<xsl:if test="@OpenInNewWindow = 'True'" >_blank</xsl:if>
</xsl:variable>
<div >
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a href="{$SafeLinkUrl}" title="{@LinkToolTip}">
<xsl:if test="$ItemsHaveStreams = 'True'">
                   <xsl:attribute name="onclick">
                     <xsl:value-of select="@OnClickForWebRendering"/>
                   </xsl:attribute>
                 </xsl:if>
                 <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
                   <xsl:attribute name="onclick">
                     <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
                   </xsl:attribute>
                 </xsl:if> 
                 <img class="image" src="{@DocumentIconImageUrl}" title="" />&#160;&#160;<xsl:value-of select="substring-before(string(@FileLeafRef),'.')" />
                 </a></div>
</xsl:template>
share|improve this answer
    
Hi tron instead of downloading document when clicked can i know how to make it to take me to the location of file. I am not getting it tried ways using fileleafref.Thanks in advance –  user2314241 Apr 21 at 20:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.