Copied to clipboard

Flag this post as spam?

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


  • Nate 143 posts 184 karma points
    Jun 24, 2010 @ 04:53
    Nate
    0

    Structured Navigation?

    I have my nav reading my content pages and they come out like this:

    Page1

    Page2

    Page3

    Page4

    Page5

     

    My boss wants it like this:

    Section 1
      Page1
      Page2

    Section 2
      Page3

    Section 3
      Page4
      Page5

    The sections are not content pages.  I'm guessing I would add properties to my document type to specify which section these should go in.  I'm not sure who to write this in XSLT though, I'm a newb :(.

     

    Here's what I have so far:

    <?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/node [string(data [@alias='umbracoNaviHide']) != '1']">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>
    </ul>

    </xsl:template>

    </xsl:stylesheet>

     

    Thanks!

     

  • Nate 143 posts 184 karma points
    Jun 24, 2010 @ 04:53
    Nate
    0

    To be more clear, the sections will not be links, just labels.

  • Sajid Riaz 142 posts 165 karma points
    Jun 24, 2010 @ 08:01
    Sajid Riaz
    0

    Hi Nate, 

    You can add multiple level 1 nodes i.e. Section1, Section2 and Section3.

    under each of these nodes add your content pages.

    So the structure will look as follows in Content Section:

    root

        Home Page

             Section1

                 Page 1

                 Page 2

           Section 2

                Page 3

           Section 3

                Page 4

                Page 5

     

    You can create a macro which will have corressponding xslt as follows:

     

    <xsl:variable name="section1" select="Section1"/>

    <xsl:variable name="section2" select="Section2"/>

    <xsl:variable name="section3" select="Section3"/>


    <xsl:template match="/">


    <ul>

    <li>Section1</li>
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@nodeName=$Section1]/node [string(data [@alias='umbracoNaviHide']) != '1']">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>
    </ul>

    <ul><li>Section2</li>
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@nodeName=$Section2]/node [string(data [@alias='umbracoNaviHide']) != '1']">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>
    </ul>


    <ul><li>Section3</li>
    <xsl:for-each select="$currentPage/ancestor-or-self::node [@nodeName=$Section3]/node [string(data [@alias='umbracoNaviHide']) != '1']">
        <li>
            <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
            </a>
        </li>
    </xsl:for-each>
    </ul>
    </xsl:template>

     

    Sajid

     

Please Sign in or register to post replies

Write your reply to:

Draft