Copied to clipboard

Flag this post as spam?

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


  • Carlo Cabrales 58 posts 77 karma points
    Sep 17, 2010 @ 17:24
    Carlo Cabrales
    0

    List all pages and sub pages from current node

    Not sure how to approach solving this (still wrapping my head around xslt) using the list whole structure from current page template. This works, however, i'd like it to output subpages in a nested list item

    • category
      • document
      • document 2
        • sub document
        • sub document 2
        • sub document 3

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet 
      version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:msxml="urn:schemas-microsoft-com:xslt" 
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    
    
    <xsl:output method="xml" omit-xml-declaration="yes" />
    
    <xsl:param name="currentPage"/>
    
    <xsl:template match="/">
    
    <!-- The fun starts here -->
      <ul>
    <xsl:for-each select="$currentPage/descendant::* [@isDoc and string(umbracoNaviHide) != '1']">
      <li>
        <a href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>
    
    </xsl:template>
    
    </xsl:stylesheet>
  • Carlo Cabrales 58 posts 77 karma points
    Sep 17, 2010 @ 17:30
    Carlo Cabrales
    0

    oh yea and i'm using the new schema

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Sep 17, 2010 @ 21:40
    Chriztian Steinmeier
    0

    Hi Carlo,

    Try this for starters, and tweak it to your liking:

    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:umbraco.library="urn:umbraco.library"
        exclude-result-prefixes="umbraco.library"
    >
    
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
        <xsl:param name="currentPage" />
    
        <xsl:template match="/">
            <h1><xsl:value-of select="$currentPage/@nodeName" /></h1>
            <ul>
                <xsl:apply-templates select="$currentPage/*[@isDoc][not(umbracoNaviHide = 1)]" />
            </ul>
        </xsl:template>
    
        <!-- Template for generic Document Type -->
        <xsl:template match="*[@isDoc]">
            <li>
                <a href="{umbraco.library:NiceUrl(@id)}">
                    <xsl:value-of select="@nodeName" />
                </a>
                <xsl:if test="*[@isDoc][not(umbracoNaviHide = 1)]">
                    <ul>
                        <xsl:apply-templates select="*[@isDoc]" />
                    </ul>
                </xsl:if>
            </li>
        </xsl:template>
    
        <!-- No output for these -->
        <xsl:template match="*[umbracoNaviHide = 1]" />
    
    
    </xsl:stylesheet>

    /Chriztian

  • Carlo Cabrales 58 posts 77 karma points
    Sep 22, 2010 @ 19:12
    Carlo Cabrales
    0

    Thanks chriztian that helped me a lot understand xslt.. however i ended up using this

     

     

    <xsl:for-each select="$currentPage/PolicyCategory">
        <tr>
         <th>
             <xsl:value-of select="@nodeName"/>
         </th>
         <th>&nbsp;</th>
         <th>&nbsp;</th>
        </tr>
            <xsl:if test="count(./PolicyDocument) &gt; 0">
          <xsl:for-each select="./PolicyDocument">
                    <tr>
      <td>&nbsp;</td>
                       <td><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="@nodeName"/></a></td>
       <td><xsl:value-of select="policyCode"/></td>
                    </tr>
                    </xsl:for-each>
            </xsl:if>
    </xsl:for-each>


  • Max 144 posts 166 karma points
    Nov 29, 2011 @ 07:42
    Max
    0

    ohk i ised this i just have another question i dont want any a href for the top level only for the sub levels how do i do it..

    like

    Category ( no hyperlink)

    -child

    -child (with hyperlinks)

     

    any code sample would be useful

Please Sign in or register to post replies

Write your reply to:

Draft