Copied to clipboard

Flag this post as spam?

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


  • Paul 55 posts 76 karma points
    Dec 27, 2011 @ 11:38
    Paul
    0

    Displaying 3 level node items in a content tree

    I have a content the following content tree:

    Content
    en
    ADocAt-Level 1 -  {uses doctype A} 
    ADocAt-Level 2  - {uses doctype B} 
    ADocAt-Level 3  - {uses doctype C}
    AnotherDocAt-Level 1  -  {uses doctype A}   
    BDocAt-Level 2  -  {uses doctype B} 
    SomeDocAt-Level 3  -  {uses doctype C} 
    CDocAt-Level 2  -  {uses doctype B}  
    OtherDocAt-Level 3  -  {uses doctype C} 
    YetAnotherDocAt-Level 1 - {uses doctype A} 

    How do iterate through the content tree using a macro created from a xslt document in order to display all the links from level 3 without had coding.

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 27, 2011 @ 12:41
    Dennis Aaen
    0

    Hi Paul,

    If I understand your question correctly you want to display the level 3 links some where on your site.

    If so you should be able to use the build-in xlst with the name: List Subpages from a changeable source. I think this xslt file vil do what you are asking for.

    But when you create the file, you have to create a matching macro. On the macro you have to add a parameter with the name  source (The alias) The name could be Pick a node, and the type have to be a content picker. When you a the xslt file, in your template, you have to pick the parent node, of the links that so be shown.

    An exampel:

    <?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"/>

    <!-- Don't change this, but add a 'contentPicker' element to -->
    <!-- your macro with an alias named 'source' -->
    <xsl:variable name="source" select="/macro/source"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul>
    <xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [@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>

    I hope this will helps you answer your question.

    /Dennis

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Dec 27, 2011 @ 13:02
    Dirk De Grave
    1

    Paul,

    Dennis' answer is fine, but you do without specifying the source param. All that needs changing is

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

    into

    <xsl:for-eachselect="$currentPage/ancestor-or-self::* [@isDoc and @level= 1]//* [@isDoc and @level = 3]">
    <li>
    <ahref="{umbraco.library:NiceUrl(@id)}">
    <xsl:value-ofselect="@nodeName"/>
    </a>
    </li>
    </xsl:for-each>

     

    Cheers,

    /Dirk

     

     

  • Paul 55 posts 76 karma points
    Dec 27, 2011 @ 13:52
    Paul
    0

    Thanks to all of you. It is displaying leaf nodes that are not included in level 3. Specifically how do I display the level 3 nodes for this level 1 node above - AnotherDocAt-Level 1 . Please see illustrated diagram above. For  multiple language support purposes, hard coding the source level is undesirable.


  • Paul 55 posts 76 karma points
    Dec 27, 2011 @ 14:04
    Paul
    0

    ok, I figured it out. I was able to use the docmentType in the <xsl:for-each/> loop.

    <xsl:for-each select="$currentPage/documentTypeAlias/AnotherDcumentTypeAlias [@isDoc and string(umbracoNaviHide) != '1']">

    ...

     

    </xsl:for-each>

     

    Thanks for your assistance all.

Please Sign in or register to post replies

Write your reply to:

Draft