Copied to clipboard

Flag this post as spam?

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


  • trfletch 598 posts 604 karma points
    Aug 06, 2009 @ 17:41
    trfletch
    0

    List child node name, then child pages of child node

    Hi,

    I have got the following structure in an umbraco 4 site:

    Projects
     - Project A
         - Photo 1
         - Photo 2
     - Project B
         - Photo 3
         - Photo 4
         - Photo 5
     - Project C
         - Photo 6
         - Photo 7

    All of the photo pages contain two properties which are media items, they are two images, one large and one small. I am using the highslide javascript to display the images but that is not really important. What I am trying to achieve is on my Projects page list the name of the child pages each followed by any photos that the child pages of the project pages contain (hope that makes sense). Basically I want the projects page to look like this:

     

                   Project A

    *Display Photo 1*

    *Display Photo 2*

     

               Project B

    *Display Photo 3*

    *Display Photo 4*

    *Display Photo 5*

     

               Project C

    *Display Photo 6*

    *Display Photo 7*

     

    So far I have the following XSLT but it is not working as I would like, it seems to be displaying all the titles next to each other, then just diplaying the first image from each project like so:

     

    Project A Project B

    *Display Photo 1*

    *Display Photo 3*

     

    Can anyone point me in the right direction as to what I need to change, it is probably something simple I just cannot work out how I need to structure it to get the result I would like. Thanks

     

    <xsl:variable name="imgThumb" select="/macro/imgThumb"/>
    <xsl:variable name="imgLarge" select="/macro/imgLarge"/>
    <xsl:template match="/">
    <!-- start writing XSLT -->
    <xsl:if test="$currentPage/node != ''">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <span class="project-name"><xsl:value-of select="@nodeName"/></span>
    <div class="photo">
    <a href="{umbraco.library:GetMedia(./node/data[@alias=$imgLarge], 'false')/data [@alias='umbracoFile']}" class="highslide" onclick="return hs.expand(this)">
    <img alt="" class="standard-image">
        <xsl:attribute name="src">
            <xsl:value-of select="umbraco.library:GetMedia(./node/data[@alias=$imgThumb], 'false')/data [@alias='umbracoFile']" />
        </xsl:attribute>
        <xsl:attribute name="width">
            <xsl:value-of select="umbraco.library:GetMedia(./node/data[@alias=$imgThumb], 'false')/data [@alias='umbracoWidth']" />
        </xsl:attribute>
        <xsl:attribute name="height">
            <xsl:value-of select="umbraco.library:GetMedia(./node/data[@alias=$imgThumb], 'false')/data [@alias='umbracoHeight']" />
        </xsl:attribute>
        </img>
    </a>
    </div>
    </xsl:for-each>
    </xsl:if>
    </xsl:template>
  • Tommy Poulsen 514 posts 708 karma points
    Aug 06, 2009 @ 21:19
    Tommy Poulsen
    0

    Hi, to get all the photos instead of only the first one in each group, you need to add a nested for-each selecting ./node subnodes. In your current situation you only select the first one in your GetMedia call.

    Regarding the positioning of the output I suspect you have some css-magic going on - try removing you spans and divs to see if your output looks correct.

    >Tommy

     

     

  • Tommy Poulsen 514 posts 708 karma points
    Aug 06, 2009 @ 21:41
    Tommy Poulsen
    100

    so something like this :

    <xsl:if test="$currentPage/node != ''">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <span class="project-name"><xsl:value-of select="@nodeName"/></span>
    <xsl:for-each select="./node">
    <div class="photo">
    <a href="{umbraco.library:GetMedia(./data[@alias=$imgLarge], 'false')/data [@alias='umbracoFile']}" class="highslide" onclick="return hs.expand(this)">
    ...
  • trfletch 598 posts 604 karma points
    Aug 07, 2009 @ 15:19
    trfletch
    0

    Hi Thanks Tommy, I have tried what you said but I get an XSLT error, I have the following code now, have I missed something somewhere?

    <xsl:if test="$currentPage/node != ''">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <span class="project-name"><xsl:value-of select="@nodeName"/></span>
        <xsl:for-each select="./node">
          <div class="photo">
          <a href="{umbraco.library:GetMedia(./data[@alias=$imgLarge], 'false')/data [@alias='umbracoFile']}" class="highslide" onclick="return hs.expand(this)">
     <img alt="" class="standard-image">
         <xsl:attribute name="src">
             <xsl:value-of select="umbraco.library:GetMedia(./node/data[@alias=$imgThumb], 'false')/data [@alias='umbracoFile']" />
         </xsl:attribute>
         <xsl:attribute name="width">
             <xsl:value-of select="umbraco.library:GetMedia(./node/data[@alias=$imgThumb], 'false')/data [@alias='umbracoWidth']" />
         </xsl:attribute>
         <xsl:attribute name="height">
             <xsl:value-of select="umbraco.library:GetMedia(./node/data[@alias=$imgThumb], 'false')/data [@alias='umbracoHeight']" />
         </xsl:attribute>
         </img>
    </a>
    </div>
    </xsl:for-each>
    </xsl:for-each>
    </xsl:if>
  • trfletch 598 posts 604 karma points
    Aug 07, 2009 @ 15:24
    trfletch
    0

    It's ok I have realised my mistake, now have the following:

    <xsl:if test="$currentPage/node != ''">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <span class="project-name"><xsl:value-of select="@nodeName"/></span>
        <xsl:for-each select="./node">
          <div class="photo">
          <a href="{umbraco.library:GetMedia(./data[@alias=$imgLarge], 'false')/data [@alias='umbracoFile']}" class="highslide" onclick="return hs.expand(this)">
     <img alt="" class="standard-image">
         <xsl:attribute name="src">
             <xsl:value-of select="umbraco.library:GetMedia(./data[@alias=$imgThumb], 'false')/data [@alias='umbracoFile']" />
         </xsl:attribute>
         <xsl:attribute name="width">
             <xsl:value-of select="umbraco.library:GetMedia(./data[@alias=$imgThumb], 'false')/data [@alias='umbracoWidth']" />
         </xsl:attribute>
         <xsl:attribute name="height">
             <xsl:value-of select="umbraco.library:GetMedia(./data[@alias=$imgThumb], 'false')/data [@alias='umbracoHeight']" />
         </xsl:attribute>
         </img>
    </a>
    </div>
    </xsl:for-each>
    </xsl:for-each>
    </xsl:if>
  • Tommy Poulsen 514 posts 708 karma points
    Aug 07, 2009 @ 17:18
    Tommy Poulsen
    0

    Glad I could help

Please Sign in or register to post replies

Write your reply to:

Draft