我有一个SharePoint问题需要帮助。我正在创建一些自定义ItemStyles来格式化Content Query Webpart(CQWP)的输出,但我需要在输出中插入“查看全部”按钮。
“查看全部”需要指向: http://www.site.com/subsite/doclibrary1/Forms/AllItems.aspx 文档库中的所有单个文件都具有以下链接: http://www.site.com/subsite/doclibrary1/FileName.doc 所以我需要一些XSL函数来从字符串末尾删除FileName.doc。
我尝试使用substring-before($variable, '.')来摆脱 .doc,但我需要找到一种方法来使用substring-after搜索系列中的最后一个正斜杠并截断孤立的文件名。
使用@Mads Hansen的帖子,这是解决问题的代码:
ItemStyle.xsl中的模板
“查看全部”需要指向: http://www.site.com/subsite/doclibrary1/Forms/AllItems.aspx 文档库中的所有单个文件都具有以下链接: http://www.site.com/subsite/doclibrary1/FileName.doc 所以我需要一些XSL函数来从字符串末尾删除FileName.doc。
我尝试使用substring-before($variable, '.')来摆脱 .doc,但我需要找到一种方法来使用substring-after搜索系列中的最后一个正斜杠并截断孤立的文件名。
使用@Mads Hansen的帖子,这是解决问题的代码:
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>
<!--Any other code you need for your custom ItemStyle here-->
</div>
</xsl:template>
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>
<xsl:with-param>
也有一个@select
,所以你可以像我的示例一样将文本值放在元素内部,也可以这样做<xsl:with-param select="$path"/>
。 - Mads Hansen