Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've found that the cleanest, easiest way to do this is to create a template in ItemStyle.xsl which selects a substring of the body content of the announcement and displays a link below to the article itself. </p> <p>After adding the following code to your ItemStyle.xsl file (in SharePoint Designer navigate to the 'Style Library/XSL Style Sheets' folder), you can modify the web part through the browser, and change the Item Style (Presentation/Styles) to 'ReadMoreAnnouncements'. This code keeps the amount of characters displayed to 190 characters (see the substring($bodyContent,1,190 function call).</p> <pre><code>&lt;xsl:template name="removeMarkup"&gt; &lt;xsl:param name="string" /&gt; &lt;xsl:choose&gt; &lt;xsl:when test="contains($string, '&amp;lt;')"&gt; &lt;xsl:variable name="nextString"&gt; &lt;xsl:call-template name="removeMarkup"&gt; &lt;xsl:with-param name="string" select="substring-after($string, '&amp;gt;')" /&gt; &lt;/xsl:call-template&gt; &lt;/xsl:variable&gt; &lt;xsl:value-of select="concat(substring-before($string, '&amp;lt;'), $nextString)" /&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:value-of select="$string" /&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;xsl:template name="ReadMoreAnnouncements" match="Row[@Style='ReadMoreAnnouncements']" mode="itemstyle"&gt; &lt;br /&gt; &lt;div class="RMAnnouncementsTitle"&gt; &lt;xsl:value-of select="@Title" /&gt; &lt;/div&gt; &lt;div class="RMAnnouncementsBody"&gt; &lt;xsl:variable name="bodyContent"&gt; &lt;xsl:call-template name="removeMarkup"&gt; &lt;xsl:with-param name="string" select="@Body"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:variable&gt; &lt;xsl:value-of select="substring($bodyContent,1,190)" /&gt; ... &lt;br /&gt; &lt;a&gt; &lt;xsl:attribute name="href"&gt; /Lists/Announcements/DispForm.aspx?ID= &lt;xsl:value-of select="@ID"&gt; &lt;/xsl:value-of&gt; &lt;/xsl:attribute&gt; &lt;xsl:attribute name="class"&gt; RMAnnouncementsMoreLink &lt;/xsl:attribute&gt; read more &lt;/a&gt; &lt;/div&gt; &lt;/xsl:template&gt; </code></pre> <p>This should definitely work, and it's very very easy to implement.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload