0

I have a custom template that I use for a CQWP with announcements. I have it set to truncate the announcement at 750 characters, then show a link with the text [Full Announcement]. The issue is when an announcement is under 750 characters, it still shows the [Full Announcement] text. This is the code:

<xsl:template name="NewsAnnounStyle" match="Row[@Style='NewsAnnounStyle']" mode="itemstyle">
    <table style="width:100%;">
        <tr>
            <td>
                <table style="width:100%;"> 
                    <tr style="background-color:#f6f6f6;"><td>
                        <xsl:variable name="SafeLinkUrl">
                            <xsl:call-template name="OuterTemplate.GetSafeLink">
                                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
                            </xsl:call-template>
                        </xsl:variable>
                        <h3 style="font-weight:600;"><a href="{$SafeLinkUrl}" style="color:#03478a;"><xsl:value-of select="@MyTitle"/></a></h3>         
                    </td></tr>
                    <tr><td>
                        <xsl:variable name="SafeLinkUrl">
                            <xsl:call-template name="OuterTemplate.GetSafeLink">
                                <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
                            </xsl:call-template>
                        </xsl:variable>
            <xsl:value-of disable-output-escaping="yes" select="substring(@MyDesc,1,750)" />
                    <xsl:if test="string-length(@MyDesc) &gt; 750">
            ... <a href="{$SafeLinkUrl}">[Full Announcement]</a><br />
                             </xsl:if>
             </td></tr>
                    <tr>
                        <td> 
                        </td>
                    </tr>
                </table>
            </td>
        </tr>           
    </table>
  </xsl:template>

Any ideas or guidance on how to have the [Full Announcements] only show when the announcement is over the 750 characters?

1 Answer 1

0

Try this

<xsl:template name="NewsAnnounStyle" match="Row[@Style='NewsAnnounStyle']" mode="itemstyle">
    <xsl:variable name="SafeLinkUrl">
        <xsl:call-template name="OuterTemplate.GetSafeLink">
            <xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
        </xsl:call-template>
    </xsl:variable>
    <table style="width:100%;">
        <tr>
            <td>
                <table style="width:100%;"> 
                    <tr style="background-color:#f6f6f6;">
                        <td>                        
                            <h3 style="font-weight:600;"><a href="{$SafeLinkUrl}" style="color:#03478a;"><xsl:value-of select="@MyTitle"/></a></h3>
                        </td>
                    </tr>
                    <tr>
                        <td>                        
                            <xsl:value-of disable-output-escaping="yes" select="substring(@MyDesc,1,750)" />
                            <xsl:if test="string-length(@MyDesc) &gt; 750">
                                <span>...</span><a href="{$SafeLinkUrl}">[Full Announcement]</a><br />
                            </xsl:if>
                        </td>
                    </tr>
                    <tr>
                        <td> 
                        </td>
                    </tr>
                </table>
            </td>
        </tr>           
    </table>
  </xsl:template>
1
  • Amal, on shorter messages (<750) it has the link functioning now, but I'd like to have the ...[Full Announcement] text not show when the entire message is under 750 characters.
    – Jim
    Jan 16, 2015 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.