Copied to clipboard

Flag this post as spam?

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


  • Graeme Paul 44 posts 64 karma points
    Oct 17, 2011 @ 13:52
    Graeme Paul
    0

    Get siblings child elements

    Hey im having difficulty getting a siblings page child elements, im trying to show all of child elements of 2011 in my archive, any suggestions?

    ----2011
    ---------- 1
    ---------- 2
    ---------- 3

    ----archive


    Thanks
    Graeme

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 17, 2011 @ 14:06
    Fuji Kusaka
    0

    Hi Graeme,

    One possible way of doing it would be inserting a macro in your Archive template page where you will display all the child nodes of 2011. 

    Something like  that should get you working

    <xsl:variable name="source" select="nodeId"/> <!-- 2011 NodeID -->

    <xsl:template match="/">
    <ul>
    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
           <href="{umbraco.library:NiceUrl(@id)}" ><xsl:value-of select="@nodeName"/></a>         
      </li>
    </xsl:for-each>
     </ul>  
    </xsl:template>
           

    But bare in mind if you change the id of this node "2011" you will also need to change it in your xslt.

    If not you can just Add some paramates in your macros with Alias "Source" name: "Source" type: Content Picker" and your XSLT 

    <xsl:variable name="source" select="/macro/source"/>      

    Then just add the Macro in your template and choose the node from which you want to display the siblings.

    hope this will help

     


  • Dan Okkels Brendstrup 101 posts 197 karma points
    Oct 17, 2011 @ 15:06
    Dan Okkels Brendstrup
    1

    If you've got your nodes structured with different doctypes, in a structure somewhat like this:

    --News [docType: ContentFolder]
    ----2011 [docType: YearFolder]
    ------1 [docType: NewsItem]
    ------2 [docType: NewsItem]
    ------3 [docType: NewsItem]

    ...then something like this should do it, in the XSLT for your archive page:

    <xsl:apply-templates select="$currentPage/ancestor::ContentFolder[@nodeName='News']/YearFolder"/>

    <xsl:template match="YearFolder">
      <h2><xsl:value-of select="@nodeName"/></h2>
      <xsl:apply-templates select="NewsItem">
        <xsl:sort select="@createDate" order="descending"/>
      </xsl:apply-templates>
    </xsl:template>

    <xsl:template match="NewsItem">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}" ><xsl:value-of select="@nodeName"/></a>
      </li>
    </xsl:template>
  • Dan Okkels Brendstrup 101 posts 197 karma points
    Oct 17, 2011 @ 15:08
    Dan Okkels Brendstrup
    0

    ...and of course wrap a <ul></ul> around those list items :)

  • Graeme Paul 44 posts 64 karma points
    Oct 18, 2011 @ 10:56
    Graeme Paul
    0

    Thanks guys, i used Fujis method to solve the problem. Thanks for the feedback as well Dan, I'm going to use your solution for something else.

    thanks again

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 19, 2011 @ 06:49
    Fuji Kusaka
    0

    Good you got it working Graeme. 

     

Please Sign in or register to post replies

Write your reply to:

Draft