2

如何在 SharePoint 的公告中创建指向该段落其余部分的链接,该链接显示以下文字:阅读更多

干杯

4

2 回答 2

1

我发现最干净、最简单的方法是在 ItemStyle.xsl 中创建一个模板,该模板选择公告正文内容的子字符串,并在下方显示文章本身的链接。

将以下代码添加到您的 ItemStyle.xsl 文件(在 SharePoint Designer 中导航到“样式库/XSL 样式表”文件夹)后,您可以通过浏览器修改 Web 部件,并将项目样式(演示/样式)更改为'阅读更多公告'。此代码将显示的字符数保持为 190 个字符(请参阅 substring($bodyContent,1,190 函数调用)。

<xsl:template name="removeMarkup">
       <xsl:param name="string" />
       <xsl:choose>
       <xsl:when test="contains($string, '&lt;')">
              <xsl:variable name="nextString">
                     <xsl:call-template name="removeMarkup">
                     <xsl:with-param name="string" select="substring-after($string, '&gt;')" />
                     </xsl:call-template>
              </xsl:variable>
              <xsl:value-of select="concat(substring-before($string, '&lt;'), $nextString)" />
       </xsl:when>
       <xsl:otherwise>
              <xsl:value-of select="$string" />
       </xsl:otherwise>
       </xsl:choose>
</xsl:template> 
<xsl:template name="ReadMoreAnnouncements" match="Row[@Style='ReadMoreAnnouncements']" mode="itemstyle">
    <br />
    <div class="RMAnnouncementsTitle">
        <xsl:value-of select="@Title" />
    </div>
    <div class="RMAnnouncementsBody">
        <xsl:variable name="bodyContent">
            <xsl:call-template name="removeMarkup">
                <xsl:with-param name="string" select="@Body"/>
            </xsl:call-template>
        </xsl:variable>
        <xsl:value-of select="substring($bodyContent,1,190)" />
        ...
        <br />
        <a>
            <xsl:attribute name="href">
                /Lists/Announcements/DispForm.aspx?ID=
                <xsl:value-of select="@ID">
                </xsl:value-of>
            </xsl:attribute>
            <xsl:attribute name="class">
                RMAnnouncementsMoreLink
            </xsl:attribute>
            read more
        </a>
    </div>
</xsl:template> 

这绝对应该有效,并且非常容易实现。

于 2009-02-19T21:23:08.523 回答
0

如果您有一个页面并且可以在 SharePoint Designer 中对其进行编辑,请尝试. 如果您想要一个以您想要的方式显示公告的 Web 部件,请尝试

于 2009-02-14T05:44:42.410 回答