Copied to clipboard

Flag this post as spam?

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


  • Phil Crowe 192 posts 256 karma points
    Jul 28, 2010 @ 12:25
    Phil Crowe
    0

    Display Banners In Folder

    Hi, Im tearing my hair out trying to understand xslt. I have created a document type called 'homepage banner'. All these homepage banners will be created under a folder in the content tree. Im trying to work out how to display all these banners on the homepage using xslt.

    currently im just trying to get it to display some text for each banner it finds but failing miserably. :(

     

    <xsl:template match="/">
    //get all the children of children
      <xsl:for-each select="currentPage/descendant::node">
       // check if its a homepage banner document type (im not sure if nodeTypeAlias is correct)
        <xsl:if test="currentPage/descendant::node[@nodeTypeAlias='Homepage Banner']">

    this is a banner

        </xsl:if>
      </xsl:for-each>
    </xsl:template>

    I cannot get my head around xslt at all.

  • Dimitris Tsoukakis 33 posts 59 karma points
    Jul 28, 2010 @ 12:33
    Dimitris Tsoukakis
    0

    You are in  a for-each loop

    try this:

     

    <xsl:for-each select="currentPage/descendant::node">
       // check if its a homepage banner document type (im not sure if nodeTypeAlias is correct)
        <xsl:if test="./[@nodeTypeAlias='Homepage Banner']">
            this is a banner
        </xsl:if>
    </xsl:for-each>

     

  • Phil Crowe 192 posts 256 karma points
    Jul 28, 2010 @ 12:51
    Phil Crowe
    0

    hmm im getting this error: Unexpected token '[' in the expression. 

    ./ -->[<-- @nodeTypeAlias='Homepage Banner'

  • Dimitris Tsoukakis 33 posts 59 karma points
    Jul 28, 2010 @ 13:05
    Dimitris Tsoukakis
    0

    :) ΟΚ. I'm not in front of an editor right now.

    Try removing the brackets

    test="./@nodeTypeAlias='Homepage Banner'"

    or

    test="@nodeTypeAlias='Homepage Banner'"

  • Phil Crowe 192 posts 256 karma points
    Jul 28, 2010 @ 13:13
    Phil Crowe
    0

    Ha, thanks for your help dimitris. Im not getting any errors now but im not getting any result either.

    heres my tree:

    homepage
    --page1
    --page2
    --page3
    --homepage banners folder
    ----banner1
    ----banner2
    ----banner3

    So i need the xslt on the homepage to show all of the banners inside the homepage banners folder. Is my syntax along the right lines or am i way off?

  • Dimitris Tsoukakis 33 posts 59 karma points
    Jul 28, 2010 @ 13:47
    Dimitris Tsoukakis
    0

    In front of currentPage you are missing the $ symbol. Is it a typo?

  • Phil Crowe 192 posts 256 karma points
    Jul 28, 2010 @ 13:56
    Phil Crowe
    0

    solved. silly typo. doh.

Please Sign in or register to post replies

Write your reply to:

Draft