Thursday, March 7, 2013

SharePoint Announcement Web part Customization (Read More..) Body

How to add a link to the rest of the paragraph in
               SharePoint Announcements?  
            
                           SharePoint Announcement Web part 
                 Customization (Read More..) option with Body 



Add Content Query Webpart. Go to Stylelibrary and Edit  "ItemStyle.xsl"
past below code after one of the </xsl:template>

===========================================================

<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>

           <xsl:if test="count(following-sibling::*)=0">

            <div class="CQWP-Footer">

              <div class="CQWP-Archive">

                <a href="/Lists/MyAnnoucement">.(More news »)</a>

              </div>

             </div>

          </xsl:if>

 </div>
</xsl:template>


===========================================================
Note: if your using Announcement Web part in Subsites replace:

"/Lists/Announcements/DispForm.aspx?ID=" to
 "/sites/Lists/Announcements/DispForm.aspx?ID=" 

Change the Item style in CNQW Item Style:




Special:
Content Editor webpart: Disable Close button:
========================================================================
<style>
.ms-toolbar INPUT {
 DISPLAY: none
}</style>
========================================================================


1 comment: