Copied to clipboard

Flag this post as spam?

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


  • Laurence Gillian 600 posts 1219 karma points
    Jan 07, 2009 @ 19:26
    Laurence Gillian
    0

    XSLT Paging

    Okay, so after being a bit confused about how to get this going at first I've come up with a solution to a problem I've been having today.

    I'm building a new site, its going to be on a flash front end, but part of the requirment is that the site must also be avalible in a html version. (for non flash clients, and also so the content can be easily sent out to people).

    Due to the design, we can only display 6, of an infinite number of content items on a page.

    So we need some kinda of paging system...

    -

    This is my idea...

    6 Items a page,

    Page 1 = Items 1 -> 6
    Page 2 = Items 7 -> 12
    Page 3 = Items 13 -> 18
    Page 4 = Items 19 -> 24

    So what we need is two variables,

    Starting Node (page number, minus 1, multiply that number by 6 and then add 1)
    Finishing Node (page number multiplied by 6)

    so I called these, $nodeStart and $nodeFinish

    and we need a page number, so thats just a query string. nice and easy to do.

    -

    This is all great, and nearly works, but I'm having trouble setting the nodeFinish. The probem is how do you filter the for-each, something like 'position=7'? I'm right in thinking this can't be done at the for-each level, as that wouldn't make sense. It needs to be done after as a filter right?

    I'm sure its really simple to do... probally just 2 words, and a number!

    I've posted the code below, so anyone can have a gander... I was quite suprised that I couldn't find any code to similar effect up on the forum. (I wrote a little bit of code to deal with what happens when there is no query string passed. Which would always be page 1.)

    If your interested in seeing how this behaves follow these links;

    http://dev.voodoodog.com/commercialsidents.aspx (no page ID)
    http://dev.voodoodog.com/commercialsidents.aspx?Page=1 (start position working, but not finish)
    http://dev.voodoodog.com/commercialsidents.aspx?Page=2 (start position working, but not finish)

    -

    [code]





    COUNT EQUALS


    QS =


    Node Start =

    Node Finish =












    [/code]

  • Comment author was deleted

    Jan 07, 2009 @ 23:24

    You can find some xslt paging examples here: http://www.nibble.be/?p=11

  • Floffy 26 posts 33 karma points
    Jan 22, 2009 @ 22:49
    Floffy
    0

    I tried the examples above, but using copy/paste gives a lot of errors. Seems like it is a problem with “ and ‘ when coping from the webpage. Is the “pure” code available anywhere?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 23, 2009 @ 08:04
    Dirk De Grave
    0

    Hmm, that is pure code. I'd suggest a global search replace on those chars and you're set!

    Regards,
    /Dirk

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    Jan 23, 2009 @ 11:46
    Dan Diplo
    0

    Have a look at my example that I just posted that is adapted from the Nibble code. I did all the hard work of escaping! o:)

  • Floffy 26 posts 33 karma points
    Jan 23, 2009 @ 18:01
    Floffy
    0

    Works great =d>
    I kept hitting new errors - nice work

Please Sign in or register to post replies

Write your reply to:

Draft