Copied to clipboard

Flag this post as spam?

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


  • Tony 11 posts 31 karma points
    Jul 07, 2011 @ 18:44
    Tony
    0

    Looping whole site for a certain doctype

    Ok so on the site I am building it has several different "news" sections.  For reasons I don't want to get into I need to have these "news" articles in different locations (see example below)

    home
    - page
    - - news landing
    - - - news article 1
    - - - news article 2
    - page
    - page
    - - news landing
    - - - news article 3
    - page
    - - news landing
    - - - news article 4
    - - - news article 5

    All of the "news articles" are a doctype called "Article" how would I loop through the whole site and pull all of the "Article" doctypes? I searched around and tried a few different options but just can't seem to figure it out.

    Any ideas?

    Thank you,
    Tony

  • Kim Andersen 1447 posts 2196 karma points MVP
    Jul 07, 2011 @ 19:12
    Kim Andersen
    2

    Hi Tony

    This snippet should do the trick:

    <xsl:template match="/">
    <xsl:variable name="root" select="$currentPage/ancestor-or-self::*[@level='1']" />
    <xsl:apply-templates select="$root//Article" />
    </xsl:template>

    <xsl:tempalte match="Article">
    <xsl:value-of select="@nodeName" /><br/>
    </xsl:template>

    /Kim A

  • Tony 11 posts 31 karma points
    Jul 07, 2011 @ 20:04
    Tony
    0

    Hey Kim,

    Thanks for the assitance once again.  Works perfect.

    Tony

  • Kim Andersen 1447 posts 2196 karma points MVP
    Jul 08, 2011 @ 08:00
    Kim Andersen
    0

    No problem Tony.

    Of course you could use a for-each instead of the apply-templates, but that's up to you. I'd go for the apply-templates version though.

    /Kim A

  • 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