0

Hi I have a DataForm Webpart and editing in SPD.

I need to truncate a column so I've replaced this line

<xsl:value-of select="@AboutUsDetailedIntroduction" disable-output-escaping="yes" />

with this:

<xsl:value-of select="substring(@AboutUsDetailedIntroduction, 1, 499 + string-length(substring-before(substring(@AboutUsDetailedIntroduction, 500),' ')))  " disable-output-escaping="yes" />

This seems to work, but I also require to add a link, as a test I've just added text but SPD seems to break and i get duplication of items as a result. It happens when I add a link or text after the line, however it appears to work above the line.

 <xsl:value-of select="substring(@AboutUsDetailedIntroduction, 1, 499 + string-length(substring-before(substring(@shAReAboutUsDetailedIntroduction, 500),' ')))  " disable-output-escaping="yes" /><a href="">Test Link</a> 

I need to add a '... Read More' with a link, ideally shown when more info is available. how can this be achieved?

UPDATE I've tried another option but same problem occurs if I add any text after line 3. It works if set disable-output-escaping set to no. But then get html tags included in output, something I want to avoid. SPD adds additional code after saving if I add anything after line 3 which gives undesired results.

<xsl:choose>
<xsl:when test="string-length(@AboutUsDetailedIntroduction) &gt; 500" >
<xsl:value-of select="substring(@AboutUsDetailedIntroduction, 1, 500)" disable-output-escaping="yes"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@AboutUsDetailedIntroduction" />
</xsl:otherwise>
</xsl:choose>
  • I don't see any issues with you XSLT - Try to add an HREF value to the a tag. Also put a space before the a tag. – Amal Hashim Jan 14 '15 at 17:11
  • Still doesnt work. I've tried another option (updated Question) but problem persists – Raj Chahal Jan 15 '15 at 8:38
0

This is working for me:

<xsl:choose>
    <xsl:when test="string-length(@AboutUsDetailedIntroduction) &gt; 500" >
        <xsl:value-of select="substring(@AboutUsDetailedIntroduction, 1, 500)" disable-output-escaping="yes"/>
        ...<a href="">Red More</a>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="@AboutUsDetailedIntroduction" />
    </xsl:otherwise>
</xsl:choose>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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