Copied to clipboard

Flag this post as spam?

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


  • miken 21 posts 71 karma points
    May 16, 2013 @ 20:31
    miken
    0

    question about xsl:for-each

    hi experts,

    I add 2 document types A and B under settings page,then I go to content page, I add one folder C  under root, another folder D under folder C. Here is hierarchy in content tab page:

    content
        my site name
                 company news
                 products
                 C
                         D
                 about us
        ....

     

    Folder C's document type is A, folder D's document type is B.

    Now I want to read data from folder C and folder D in homepage.I don't know how to write xsl:for-each. please help, thanks a lot.

     

     

     

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    May 16, 2013 @ 20:46
    Chriztian Steinmeier
    101

    Hi miken,

    There's loads of ways you could do that, but here's a simple approach where you set a couple of variables to point to the documents you need to query:

    <xsl:param name="currentPage" />
    <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    
    <xsl:variable name="C" select="$siteRoot/C" />
    <xsl:variable name="D" select="$C/D" />
    
    <xsl:template match="/">
        <h2>Here's a value from C:</h2>
        <p><xsl:value-of select="$C/@nodeName" /></p>
    
        <h2>Here's a value from D:</h2>
        <p><xsl:value-of select="$D/@createDate" /></p>
    </xsl:template>
    

    /Chriztian

  • miken 21 posts 71 karma points
    May 16, 2013 @ 22:24
    miken
    0

    thanks Chriztian.

     

     

  • 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