Copied to clipboard

Flag this post as spam?

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


  • Jeffrey Schoemaker 408 posts 2138 karma points MVP 8x c-trib
    Mar 24, 2010 @ 14:34
    Jeffrey Schoemaker
    0

    Show position of

    Hi all,


    I have the following problem; I have a list with newsitems and when I show a newsitem I want to display "This is newsitem x of y".

    Getting the y is simple, because I just count the number of nodes under its parent

    <xsl:value-of select="count($currentPage/parent::node/node)"/>

    But how can I get which newsitem it is (number 1, 2, 3 or whatever) without looping through all newsitems. First I thought that $currentPage/@sortOrder was right, but if you delete an item (for example:2) than the @sortorder of article 1 stays 1 and the @sortorder of article 3 stays 3, but article 3 is no longer newsitem 3 of y but newsitem 2 of y (because article 2 is deleted)

    I hope anybody can help

    Jeffrey

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Mar 24, 2010 @ 14:43
    Chriztian Steinmeier
    0

    Hi Jeffrey,

    Depending on the context, you should be able to use the position() function - something like:

    <xsl:value-of select="concat($currentPage/position(), ' of ', count($currentPage/../node))" />

    /Chriztian

  • Jeffrey Schoemaker 408 posts 2138 karma points MVP 8x c-trib
    Mar 24, 2010 @ 14:58
    Jeffrey Schoemaker
    0

    Hi Chriztian,

    I'm not in a for-each loop but I'm one the page of that newsitem, so I can't use /position()

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Mar 24, 2010 @ 15:09
    Chriztian Steinmeier
    0

    Hi Jeffrey,

    OK - then you should be able to add one to the number of preceding-siblings:

    <xsl:value-of select="concat(count($currentPage/preceding-sibling::node) + 1, ' of ', count($currentPage/../node))" />

    /Chriztian

  • Jeffrey Schoemaker 408 posts 2138 karma points MVP 8x c-trib
    Mar 24, 2010 @ 15:15
    Jeffrey Schoemaker
    0

    Great! Thanks a lot!

Please Sign in or register to post replies

Write your reply to:

Draft