Frage SP 2010 Announcement web part - truncate/char limit issue

  • Donnerstag, 3. Mai 2012 22:58
     
     

    Yes, there are old threads on this topic but most of them for MOSS or prior versions or without any resolutions. This thread is close but solution doesn't work for me. Feel free to forward any working link.                                           

    We upgraded from MOSS 2007 to SP 2010. We are using Announcement web part with much large Announcement text (HTML tables etc) which exceeds allowed size (250 char I think). Right now text truncates with "..."

    Is there any working solution to this problem for SP 2010 SP1?  Thank you !!!


    Manish

Alle Antworten

  • Freitag, 4. Mai 2012 05:36
     
     

    Hi

    use substring XPATH function in your code

    Infos about them, http://www.w3schools.com/xpath/xpath_functions.asp


    Romeo Donca, Orange Romania (MCSE, MCTS, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • Freitag, 4. Mai 2012 16:55
     
     
    Hi romeo donca, thanks for your response. I'm aware of XPATH technology. How does XPATH solves this problem? Can you provide more details? Any blogs/links will be really appreciated. Thank you!!!

    Manish

  • Freitag, 4. Mai 2012 19:54
     
     

    Hi

    i will come back with a real example for you

    Regards


    Romeo Donca, Orange Romania (MCSE, MCTS, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • Montag, 14. Mai 2012 17:59
     
     
    I would very much like to know if you found an answer for this.  I have attempted a few different ways of doing this, including this but none have actually worked.  I cannot believe Microsoft would take some that was so easily changed in 2007 and make it so impossible in 2010.  
  • Montag, 14. Mai 2012 19:57
     
      Enthält Code

    Hi

    i couldn't create by my self the example, but i reproduced the example you provided, and it's working

    What you have to know from the link, if you aren't very familiar with the code

    There are 3 code blocks as bellow

    First one

    <xsl:call-template name="FirstNWords">
             <xsl:with-param name="TextData" select="$BodyText"/>
              <xsl:with-param name="WordCount" select="10"/>
              <xsl:with-param name="MoreText" select="'...'"/>
            </xsl:call-template>

    This block will show the desired number of words - in this case 10, calling a variable $Bodytext. This code should be added in your page 

    The easiest way,  if you added the web part with only 2 column, Title and body, look for the code like this one

    <tr>
    		  <xsl:if test="position() mod 2 = 1">
    			<xsl:attribute name="class">ms-alternating</xsl:attribute>
    			</xsl:if>
    			<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
    				<td class="ms-vb" width="1%" nowrap="nowrap">
    					<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>
    				</td>
    			</xsl:if>
    			<td class="ms-vb">
    				<xsl:value-of select="@Title"/>
    			</td><td class="ms-vb">
    				<xsl:value-of select="@Body" disable-output-escaping="yes" /></td><td class="ms-vb">
    				</td></tr>

    So, if you replace column for  @body column, the code will look like

    <tr>
    			<xsl:if test="position() mod 2 = 1">
    				<xsl:attribute name="class">ms-alternating</xsl:attribute>
    			</xsl:if>
    			<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
    				<td class="ms-vb" width="1%" nowrap="nowrap">
    					<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="view"></span>
    				</td>
    			</xsl:if>
    			<td class="ms-vb">
    				<xsl:value-of select="@Title"/>
    			</td><td class="ms-vb">
     <xsl:call-template name="FirstNWords">
             <xsl:with-param name="TextData" select="$BodyText"/>
              <xsl:with-param name="WordCount" select="10"/>
    
    
              <xsl:with-param name="MoreText" select="'...'"/>
    
            </xsl:call-template>
    				</td></tr>


    In this momment you will receive an error message: no Template exist:

    It's the momment to insert the templates:These are:

    <xsl:template name="FirstNWords">
        <xsl:param name="TextData"/>
        <xsl:param name="WordCount"/>
        <xsl:param name="MoreText"/>
        <xsl:choose>
          <xsl:when test="$WordCount &gt; 1 and (string-length(substring-before($TextData, ' ')) &gt; 0 or string-length(substring-before($TextData, ' ')) &gt; 0)">
           <xsl:value-of select="concat(substring-before($TextData, ' '), ' ')" disable-output-escaping="yes"/>
            <xsl:call-template name="FirstNWords">
              <xsl:with-param name="TextData" select="substring-after($TextData, ' ')"/>
              <xsl:with-param name="WordCount" select="$WordCount - 1"/>
              <xsl:with-param name="MoreText" select="$MoreText"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:when test="(string-length(substring-before($TextData, ' ')) &gt; 0 or string-length(substring-before($TextData, ' ')) &gt; 0)">
            <xsl:value-of select="concat(substring-before($TextData, ' '), $MoreText)" disable-output-escaping="yes"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$TextData" disable-output-escaping="yes"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>
    
    
    
    <xsl:template name="StripHTML">
        <xsl:param name="HTMLText"/>
        <xsl:choose>
          <xsl:when test="contains($HTMLText, '&lt;')">
            <xsl:call-template name="StripHTML">
              <xsl:with-param name="HTMLText" select="concat(substring-before($HTMLText, '&lt;'), substring-after($HTMLText, '&gt;'))"/>
            </xsl:call-template>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="$HTMLText"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>


    and should be inserted, in the end of the code, where oyu see all other templates .

    The last step, is to define the variable $bodytext, and the code is

    <xsl:variable name="BodyText">
          <xsl:call-template name="StripHTML">
            <xsl:with-param name="HTMLText" select="@Body"/>
          </xsl:call-template>
        </xsl:variable>

    and should be inserted just after

    <xsl:template name="dvt_1.rowview">
    						
    		<xsl:param name="Pos" />

    For any other issues, don't hesitate to contact me


    Romeo Donca, Orange Romania (MCSE, MCTS, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.


  • Montag, 14. Mai 2012 21:43
     
     

    I was able to implement this change with the code provided, although via another site.  My issue is that I am trying to ADD length to our Announcements.  This method works for shortening, but if I change the number of words, say to 50, I still hit the 250 character limit.  Is there a way you know of to EXPAND the amount of characters?