How can I create a link to the rest of the paragraph in an announcement in SharePoint, that displays the word: read more
Cheers
How can I create a link to the rest of the paragraph in an announcement in SharePoint, that displays the word: read more
Cheers
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.
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).
<xsl:template name="removeMarkup">
<xsl:param name="string" />
<xsl:choose>
<xsl:when test="contains($string, '<')">
<xsl:variable name="nextString">
<xsl:call-template name="removeMarkup">
<xsl:with-param name="string" select="substring-after($string, '>')" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="concat(substring-before($string, '<'), $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>
This should definitely work, and it's very very easy to implement.
Ryan, I know I'm soo late answering you but yes, thanks, just checked again this website and I'm trying to implement it. I opened in SharePoint designer the ItemStyle.xsl and checked it out then tried to add your code but it doesn't paste it?! Have I missed an other step?
I'm new at Sharepoint designer and I am very careful with it.
Many thanks again! Nassi