Copied to clipboard

Flag this post as spam?

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


  • Alexandru 112 posts 272 karma points
    Oct 03, 2013 @ 09:31
    Alexandru
    0

    XSLT string limit

    I would like to only show a part of the blog posts on my blogs homepage.

    RIght now I use this to show the whole content of the blog post:

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

    I would rather only show a certain number of characters, or a number of paragraphs instead of just slicing the div to a fixed size because doing so would slice some of the paragraphs right through the middle.

    Thanks!

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 03, 2013 @ 09:34
    Fuji Kusaka
    1

    Try Truncate

    <xsl:value-ofselect="umbraco.library:TruncateString(umbraco.library:StripHtml(./bodyText), 100,'...')"/>
  • Alexandru 112 posts 272 karma points
    Oct 03, 2013 @ 09:58
    Alexandru
    0

    Works, but it removes any image or link from the text. Any way around this?

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 03, 2013 @ 10:01
    Dennis Aaen
    100

    Try this one:

    <xsl:value-of select="umbraco.library:TruncateString(./bodyText, 100,'...')"/>

    /Dennis

  • Alexandru 112 posts 272 karma points
    Oct 03, 2013 @ 10:10
    Alexandru
    0

    As hilarious as it sounds, this screws up part of the layout on only SOME of the posts. However, it keeps the links but I have noticed it is limited to just over 2000 characters. Also, some blog posts don't get the "..." at the end as they should.

    enter image description here

    As you can see, the bottom of the first post is ruined, the second post looks well but the third one is missing the "...". Still, these dots are not important to me, I have to add a span with the link to the full blog post anyways.

  • Alexandru 112 posts 272 karma points
    Oct 03, 2013 @ 10:14
    Alexandru
    1

    Sorry, you can disregard the previous post. It was a CSS issue. I forgot to turn off the overflow and the max-height that I had previously been using.

    Thank you guys!

  • Alexandru 112 posts 272 karma points
    Oct 03, 2013 @ 10:15
    Alexandru
    0

    Actually no, it isn't it still messes up.....

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 03, 2013 @ 10:28
    Dennis Aaen
    1

    Hi Alexandru,

    Should the be any images on the list of blogposts, or do you just want clear text.

    If you have to show some images to to the blogpost I would suggest you to look here at Lee KelleherĀ“s answer or some other of the anwsers, it might help you

    http://our.umbraco.org/forum/developers/xslt/32242-TruncateString-breaks-html-%28bug%29?p=1#comment118712

    /Dennis

  • Alexandru 112 posts 272 karma points
    Oct 03, 2013 @ 10:33
    Alexandru
    0

    Yeah, what he says makes sense. I will dig into it and get back with an answer. cheers!

  • Alexandru 112 posts 272 karma points
    Oct 03, 2013 @ 10:46
    Alexandru
    0

    I can't download the code files that he suggests. I have sent him a message, hopefully he will reply. Thanks for pointing him out to me!

Please Sign in or register to post replies

Write your reply to:

Draft