Copied to clipboard

Flag this post as spam?

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


  • Magnus Jonsson 33 posts 53 karma points
    Jan 24, 2011 @ 13:25
    Magnus Jonsson
    0

    Paging long "Body Text" with XSLT?

    Hi,

    I'm working on a site where the Body Text for a node sometimes can become very long and could use som paging. I'm looking for away to create paging for the Body Text property. Is this possible to do with XSLT? Any help would be very appriciated!

    Best regards,

    Magnus

  • Tom Smith 98 posts 172 karma points
    Jan 24, 2011 @ 15:35
    Tom Smith
    0

    Hi Magnus,

    I wrote an XSLT extension a while back to display the first n words of a blog post (with well formed HTML).

    (Blog post on topic here: http://www.thecogworks.co.uk/blog/2011/1/21/n-word-preview-for-blog4umbraco)

    You might be able to use the code to spit out x words "per page",

    Either way, an xslt extension would be the way I would approach the problem as I can't think of a way of doing it in XSLT without stripping out all the HTML. (HTML needs to be stripped out or well formed as otherwise you could get stuck in an open tag at the end of a page)

    If you don't need HTML in the body text, just use the umbraco library strip html method (http://our.umbraco.org/wiki/reference/umbracolibrary/striphtml) and then the XSLT sub string method; http://zvon.org/xxl/XSLTreference/Output/function_substring.html

    This allows you to output x characters of a string between position n and position n+i, so you could use it for paging. (e.g. 10,000 characters per page) 

    Many Thanks,

    Tom

Please Sign in or register to post replies

Write your reply to:

Draft