Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jesper Pedersen 12 posts 32 karma points
    Jun 07, 2011 @ 16:47
    Jesper Pedersen
    0

    How to limit the output lenght?

    Hello...

    The following line, displays all my text in my blogposts.

    <xsl:value-of select="$post/bodyText" disable-output-escaping="yes"/>

    What i want is to display only, etc. 50 words, so that my frontpage look clean.

    But how do i do that, whitout destroying th html?

  • Profiterole 232 posts 264 karma points
    Jun 07, 2011 @ 17:39
    Profiterole
    0

    <xsl:value-of select="umbraco.library:TruncateString($post/bodyText, number(50), '...')" disable-output-escaping="yes" />

    but it's a number of characters.

  • Jesper Pedersen 12 posts 32 karma points
    Jun 07, 2011 @ 17:53
    Jesper Pedersen
    0

    Thanks !!! :)

  • Mdogggg 5 posts 35 karma points
    Aug 28, 2012 @ 12:57
    Mdogggg
    0

    Just what I was looking for.  Thanks :)

  • Jon Cousins 5 posts 25 karma points
    Feb 05, 2013 @ 12:55
    Jon Cousins
    0

    What about to the nearest word?

    For example, using the string:
    "This is a string longer than 35 characters."
    Limited to 35 characters, it would normally be:
    "This is a string longer than 35 cha..." 

    Can I have it 'snap' to the nearest word? So instead it would output:
    "This is a string longer than 35..."

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Feb 08, 2013 @ 15:59
    Dennis Aaen
    0

    Hi Jon,

    I don't know if you have found a solution for your question.

    But if you don´t have the Ucomponents package, can maybe do what you ask for.

    In the Ucomponents package there is a extension method named strings, with this XSLT extension you should be able to break a string by
    nearest word, as I read the documentation.

    I must say, that I don´t have used this XSLT extension myself, but I think it can helps you out here.

    The Ucomponents package: http://ucomponents.codeplex.com/releases/view/100480 and the documentation for the string
    extension method: http://ucomponents.org/xslt-extensions/strings

    I hope this can help you to solve your question.

    /Dennis

     

  • Dennis Aaen 4457 posts 17970 karma points admin hq c-trib
    Feb 13, 2013 @ 14:53
    Dennis Aaen
    0

    Hi Jon,

    Could you use my inputs to find a solution, for 'snap' to the nearest word?

    /Dennis

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies