Copied to clipboard

Flag this post as spam?

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


  • [email protected] 378 posts 1915 karma points MVP 4x c-trib
    Mar 24, 2010 @ 14:34
    jeffrey@umarketingsuite.com
    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 2726 posts 8320 karma points MVP 4x 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

  • [email protected] 378 posts 1915 karma points MVP 4x c-trib
    Mar 24, 2010 @ 14:58
    jeffrey@umarketingsuite.com
    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 2726 posts 8320 karma points MVP 4x 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

  • [email protected] 378 posts 1915 karma points MVP 4x c-trib
    Mar 24, 2010 @ 15:15
    jeffrey@umarketingsuite.com
    0

    Great! Thanks a lot!

  • 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