Copied to clipboard

Flag this post as spam?

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


  • Ryan Jeppesen 3 posts 22 karma points
    Oct 30, 2012 @ 15:45
    Ryan Jeppesen
    0

    Get children of current page

    Im trying to retrieve subpages of the current page and displaying a list with them. 

    I can only retrieve the sub nodes with:

    <xsl:for-each select="$currentPage/*">

    I can not use below like on the umbraco wiki example

    <xsl:for-each select="$currentPage/node">

     And furthermore im not able to insert href with: 

    <xsl:value-of select="umbraco.library:NiceUrl(current()/@id)"/>

    My XSLT:

    <xsl:param name="currentPage"/>    
        
        <xsl:template match="/">
            <ul>
                <xsl:if test="count($currentPage/*) &gt; 0">
                    <xsl:for-each select="$currentPage/*">
                        <li>
                            <a href="{umbraco.library:NiceUrl(current()/@id)}">
                                <xsl:value-of select="current()/@nodeName"/>
                            </a>
                        </li>
                    </xsl:for-each>
                </xsl:if>
            </ul>
        </xsl:template>
    

    Can anyone see what im doing wrong?

    Thanks in advance

    /Ryan

     

     

     

  • Fuji Kusaka 2203 posts 4220 karma points
    Oct 30, 2012 @ 15:58
    Fuji Kusaka
    0

    Hi Ryan,

    Change your XSLT to

    <xsl:if test="$currentPage/* [@isDoc]">
    <xsl:for-each select="./*[@isDoc][not(umbracoNaviHide = 1)]">
    <a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a>
    </xsl:for-each> 
    </xsl:if>
  • Pasang Tamang 252 posts 394 karma points
    Oct 30, 2012 @ 16:06
    Pasang Tamang
    0

    Hi Ryan,

    Please check the xslt examples of new updated schema (U4.5+) here http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema.

    Thanks
    PTamang

  • Ryan Jeppesen 3 posts 22 karma points
    Oct 30, 2012 @ 19:56
    Ryan Jeppesen
    0

    Hi

    Ahh outdated wiki page :) 

    Thanks a lot both.

  • Ryan Jeppesen 3 posts 22 karma points
    Oct 30, 2012 @ 23:20
    Ryan Jeppesen
    0

    Can you guys help with a similar problem. On another page i need to count the children of another node. But cant seem to get it working with the code below:

        <xsl:param name="currentPage"/>
        <xsl:param name="calender" select="/macro/calender"/>   
    
        <xsl:template match="/">
            ID: <xsl:copy-of select="$calender"/>
            <br />
            Children test:<xsl:value-of select="count($calender/*[@isDoc][not(umbracoNaviHide = 1)])"/>
            <br />
            Children test 2: <xsl:value-of select="count($calender/child::*[@isDoc][not(umbracoNaviHide = 1)])"/>
    

     

     

  • 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