I have a SharePoint problem that I need help with. I am creating some ItemStyles custom elements to format the output of the content request web part (CQWP), but I need to insert the "view all" button in the output.
Show everything should point to: http://www.site.com/subsite/doclibrary1/Forms/AllItems.aspx
All individual files in the document library have a link: http://www.site.com/subsite/doclibrary1/FileName.doc
So, I need some XSL functions to remove FileName.doc from the end of the line.
I tried using substring-before ($ variable, '.') To get rid of .doc, but then I need to find a way to use the substring after finding the LAST slash in the series and truncate the orphaned file name.
Using the @Mads Hansen post, this is the code that resolved the issue:
Template in ItemStyle.xsl
<xsl:template name="ImpDocs" match="Row[@Style='ImpDocs']" 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="ViewAllLink"> <xsl:call-template name="OuterTemplate.getCleanURL"> <xsl:with-param name="path" select="@LinkUrl"/> </xsl:call-template> </xsl:variable> <div class="DocViewAll"> <a href="{$ViewAllLink}Forms/AllItems.aspx" title="View all">View All</a> </div> </xsl:template>
Template in ContentQueryMain.xsl
<xsl:template name="OuterTemplate.getCleanURL"> <xsl:param name="path" /> <xsl:choose> <xsl:when test="contains($path,'/')"> <xsl:value-of select="substring-before($path,'/')" /> <xsl:text>/</xsl:text> <xsl:call-template name="OuterTemplate.getCleanURL"> <xsl:with-param name="path" select="substring-after($path,'/')" /> </xsl:call-template> </xsl:when> <xsl:otherwise /> </xsl:choose> </xsl:template>
source share