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 に答える