Copied to clipboard

Flag this post as spam?

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


  • Wachter Bernd 48 posts 68 karma points
    Nov 24, 2009 @ 13:53
    Wachter Bernd
    0

    Home Menue at the Top

    Hello,

    I have make my Menue with the fpllowing Code (XSLT)

    I have 2 Languages in my Homepage
    and my Folder Structure in Umbraco look like this

    - de
      - Sub SItes of German Homepage
    - en
       -Sub Sites of English Homepage

    And when i show my Menue with this Script i have not a Menue Point for the Home
    My User cannot click Home to come to the Homepage Start ?

    When i start with the Root Node 0 i have a Menue Point with the Name
    de
    en

    This i will not ! I must have a Menue Link with the Name Home at the top of my Menue

    My Menue Must show like so :

    - Home
      - Menue 1
      - Menue 2
        - Submenue1
        - Submenue 2

    What must i do does i have always a Menuepoint with the Name Home and link to my Home Site de

    Here is my Demo Site : http://beta.almrausch.at

    and at the Top of al my Menue Point must i have always a Menuepoint with the Name HOME

    -------------------------------------------------------------------------------------------------------------------------------------

    <?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"
     exclude-result-prefixes="msxml umbraco.library">

    <xsl:output method="html" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage" />

    <!--This sets the level that the nav starts at and tells us if we should recurse through child elements-->
    <xsl:variable name="startDepth" select="/macro/startingLevel" />
    <xsl:variable name="recurse" select="/macro/recurse" />
    <xsl:variable name="selectBranches" select="/macro/selectBranches"></xsl:variable>
    <xsl:variable name="maxMenuDepth" select="/macro/maxMenuDepth"></xsl:variable>
    <xsl:variable name="forceNode" select="/macro/forceNode"></xsl:variable>
    <xsl:variable name="walkChildren" select="/macro/expandChildren"></xsl:variable>
    <xsl:variable name="forceHome" select="/macro/forceHome"></xsl:variable>
    <!--Alternate page title variable in here-->
     
    <!--Styles for the navigation-->
    <xsl:variable name="ulBaseClass" select="/macro/ulBaseClass"></xsl:variable>
    <xsl:variable name="branchClass" select="/macro/branchClass"></xsl:variable>
    <xsl:variable name="selectedClass" select="/macro/selectedClass"></xsl:variable>

    <xsl:variable name="startLevel">
      <xsl:choose>
        <xsl:when test="$startDepth >= 0">
          <xsl:value-of select="$startDepth"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$currentPage/@level"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

      <!--This calls first iteration of the navigation, sending the first node at the correct depth found in the ancestors of the current page-->
    <xsl:template match="/">
     
      <xsl:choose>
        <xsl:when test="$forceNode">
          <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById($forceNode)"></xsl:variable>
          <xsl:call-template name="nodeIterator">
            <xsl:with-param name="parentNode" select="$currentNode/ancestor-or-self::node[@level=$startLevel] [string(data [@alias='umbracoNaviHide']) != '1']" />
            <xsl:with-param name="pseudoCurrentPage" select="$currentNode" />
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:variable name="currentNode" select="$currentPage"></xsl:variable>
          <xsl:call-template name="nodeIterator">
            <xsl:with-param name="parentNode" select="$currentNode/ancestor-or-self::node[@level=$startLevel] [string(data [@alias='umbracoNaviHide']) != '1']" />
            <xsl:with-param name="pseudoCurrentPage" select="$currentNode" />
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>

    <xsl:template name="nodeIterator">
        <xsl:param name="parentNode" />
        <xsl:param name="pseudoCurrentPage" />
        <!-- do not show info doc node types-->

      <xsl:variable name="calculatedMenuDepth" select="($parentNode/@level - $startLevel)+1" />

      <ul>

            <xsl:attribute name="class">
              <xsl:choose>
                <xsl:when test="$calculatedMenuDepth = 1">
                  <xsl:value-of select="concat($ulBaseClass, ' lv', $calculatedMenuDepth)" />
                </xsl:when>
                <xsl:when test="$calculatedMenuDepth > 1">
                  <xsl:value-of select="concat('lv', $calculatedMenuDepth)" />
                </xsl:when>
              </xsl:choose>
           </xsl:attribute>

         
     <xsl:if test="$forceHome = 1 and $calculatedMenuDepth = 1">
              <!-- Create the class for the li element-->
              <li>
                <xsl:attribute name="class">
                  <xsl:if test="$currentPage/ancestor-or-self::node[@level=1]/@id = $currentPage/@id">
                    <xsl:value-of select="concat($selectedClass,' ')"/>
                  </xsl:if>
                  <xsl:value-of select="'hasChildren '"/>
                </xsl:attribute>


                <a href="{umbraco.library:NiceUrl($currentPage/ancestor-or-self::node[@level=1]/@id)}">

                  <xsl:attribute name="class">
                    <xsl:if test="$currentPage/ancestor-or-self::node[@level=1]/@id = $currentPage/@id">
                      <xsl:value-of select="concat($selectedClass,' ')"/>
                    </xsl:if>
                  </xsl:attribute>

                  <!--set the innerText for the a element-->
                  <xsl:value-of select="$currentPage/ancestor-or-self::node[@level=1]/text()"/>

                  <xsl:if test="string($currentPage/ancestor-or-self::node[@level=1]/text()) = ''">
                    <xsl:value-of select="$currentPage/ancestor-or-self::node[@level=1]/@nodeName"/>
                  </xsl:if>
                </a>
              </li>
            </xsl:if>
            <!--End force home-->
           
           
            <!--for each node in the parent node that is not hidden by Umbraco-->
            <xsl:for-each select="$parentNode/node [string(data [@alias='umbracoNaviHide']) != '1']">

              <!--Set the current node id i.e. the node we have looped to not the current page-->
              <xsl:variable name="currentNodeID" select="./@id" />

              <!--Is the node a branch? i.e. are there children and is it in the colletion of ancestor nodes -->
              <xsl:variable name="isBranch">
                <xsl:choose>
                  <xsl:when test="$pseudoCurrentPage/ancestor-or-self::node[@id = $currentNodeID]/child::node">1</xsl:when>
                </xsl:choose>
              </xsl:variable>

              <!--Is the node selected? i.e. is it the same as the currentPage node-->
              <xsl:variable name="isSelected">
                <xsl:choose>
                  <xsl:when test="$pseudoCurrentPage/@id = $currentNodeID">1</xsl:when>
                </xsl:choose>
              </xsl:variable>

              <xsl:variable name="isSelectedBranch">
                <xsl:choose>
                  <xsl:when test="$isBranch = 1 and $selectBranches = 1">1</xsl:when>
                </xsl:choose>
              </xsl:variable>

              <xsl:variable name="hasChildren">
                <xsl:choose>
                  <xsl:when test="./node">1</xsl:when>
                </xsl:choose>
              </xsl:variable>

              <li>
     
                <!-- Create the class for the li element-->
                <xsl:attribute name="class">
                  <xsl:if test="$isSelected = 1"> <xsl:value-of select="concat($selectedClass,' ')"/> </xsl:if>
                  <xsl:if test="$isSelectedBranch = 1"> <xsl:value-of select="concat($branchClass,' ')"/> </xsl:if>
                  <xsl:if test="$hasChildren = 1"><xsl:value-of select="'hasChildren '"/></xsl:if>
                </xsl:attribute>

                <a href="{umbraco.library:NiceUrl(@id)}">
                 
                  <xsl:attribute name="class">
                    <xsl:if test="$isSelected = 1"> <xsl:value-of select="concat($selectedClass,' ')"/> </xsl:if>
                    <xsl:if test="$isSelectedBranch = 1"> <xsl:value-of select="concat($branchClass,' ')"/> </xsl:if>
                  </xsl:attribute>

                  <!--set the innerText for the a element-->
                  <xsl:value-of select="./data[@alias='contentPageTitle']/text()"/>

                 <xsl:if test="string(./data[@alias='contentPageTitle']/text()) = ''"> 
                      <xsl:value-of select="@nodeName"/>
                  </xsl:if>
                </a>

                <!-- if it's a branch recurse through it's children-->
                <xsl:if test="((($isBranch = 1 and $recurse = 1) or ($walkChildren = 1 and $currentPage/descendant-or-self::node[@id = $currentNodeID]/child::node)) and $maxMenuDepth &gt;= $calculatedMenuDepth)">
                  <xsl:call-template name="nodeIterator">
                    <xsl:with-param name="parentNode" select="." />
                    <xsl:with-param name="pseudoCurrentPage" select="$pseudoCurrentPage" />
                  </xsl:call-template>
                </xsl:if>

              </li>

            </xsl:for-each>

          </ul>
      </xsl:template>

    </xsl:stylesheet>

  • dandrayne 1138 posts 2262 karma points
    Nov 24, 2009 @ 15:16
    dandrayne
    0

    Are you using startdepth of 0?  If so, try using 1.

    Dan

  • Tim 225 posts 690 karma points
    Nov 24, 2009 @ 15:48
    Tim
    0

    Hi,

    It looks like you are using the Flexible Navigation Package.

    Can you show how you are including the macro on the page please, for example: <umbraco:Macro startingLevel="2" recurse="1" selectBranches="1" maxMenuDepth="999" ulBaseClass="vertical" branchClass="branch" selectedClass="selected" Alias="[COG]Navigation" runat="server"></umbraco:Macro>

    That'll give me a better idea ofwhat may be going wrong.

    Tim

     

  • Wachter Bernd 48 posts 68 karma points
    Nov 24, 2009 @ 17:17
    Wachter Bernd
    0

    Hi Tim,

    Here is my Code were insert the Macro:

    <umbraco:Macro startingLevel="1" recurse="1" selectBranches="1" maxMenuDepth="2" ulBaseClass="vertical" branchClass="branch" selectedClass="selected" forceNode="" expandChildren="0" forceHome="0" Alias="[COG]Navigation" runat="server"></umbraco:Macro>

    My Problem is when i set forceHome to 1 then shows me Home like this:

    de for the German Start Site

    en for the English Startsite

    because my Folder Structur in Umbraco is this:
    ------------------------------------------------------------------------------

    This is my German Homepage Structure in Umbraco:

    - de
      - Menue 1
      - Menue 2
        - Sub Menue1

    This is my English Homepage Structure in Umbraco

    - en
      - Menue 1
      - Menue 2
        - Sub Menue1

    ----------------------------------------------------------------------------------

    And when i set forceHome to 1 then shows me the Text de and en for Home

    And i must have not the Text de or en as the First Node !!!

    My Structure must like this:

    - HOME
      - Menue 1
      - Menue 2
        - Sub Menue1

    I have a Language Selector from you this must have this Structure de and en to switch the Language for my Page !!!

    The only what i want is not show the Text de and en in my Homepage
    I must show HOME as the Home Node of my Homepage!

    Thanks

     

     

  • Tim 225 posts 690 karma points
    Nov 24, 2009 @ 18:03
    Tim
    0

    Hi,

    I think I understand what you're after:

    You want to display the text Home rather than en or de.

    If this is the case then you need to set the following line:

    <xsl:value-of select="$currentPage/ancestor-or-self::node[@level=1]/text()"/>

    to something like: 

    <xsl:value-of select="$currentPage/ancestor-or-self::node[@level=1] [@alias='contentPageTitle']/text()"/>

    This will display the content item contentPageTitle instead of the node name. To use this you would need to set up a property on your document type with the alias of contentPageTitle.

    For example:

    Name: Content Title

    Alias: contentPageTitle

    Type: Textstring

    Tim

  • Wachter Bernd 48 posts 68 karma points
    Nov 24, 2009 @ 19:14
    Wachter Bernd
    0

    Hi Tim,

    Thank you for the answer.

    Yes this it wat i mean ....

    Can i change the XSL so does only the Root Nodes become the Name where i set in the new Property ???

    as the DE and EN Root Node become the Text from my new Property

    and al other Levels become the Text Normal from the Standard Name Textbox ???

     

  • Tim 225 posts 690 karma points
    Nov 25, 2009 @ 08:56
    Tim
    0

    If you do not enter any text in the contentPageTitle textbox, the navigation will use the node name.

    This should all work without modifying the XSLT further. Let me know if it doesn't and what happens and I'll point you in the right direction.

    Tim

  • Wachter Bernd 48 posts 68 karma points
    Nov 25, 2009 @ 15:01
    Wachter Bernd
    0

    Hi Tim,

    I have make this and it works ..

    But he works only for the Levels 1 , it works not for my de en (Home Level)

    It shows always de and en not my Text from my Property

    Here is my Code where i have changed

    ---------------------------------------------------------------------------------------------------------------------------------------------- 

    <!--set the innerText for the a element-->
                 
      <xsl:value-of select="$currentPage/ancestor-or-self::node[@level=1] [@alias='contentPageTitle']/text()"/>
                  <xsl:if test="string($currentPage/ancestor-or-self::node[@level=1]/text()) = ''">
                    <xsl:value-of select="$currentPage/ancestor-or-self::node[@level=1]/@nodeName"/>
                  </xsl:if>
                </a>
              </li>
            </xsl:if>
            <!--End force home-->

    --------------------------------------------------------------------------------------------------------------------------------------------------

    I hope you unsderstand me ...
    I have set in my Masterpage forceHome="1" does the Menue Shows my Home Level
    I have set the Text "HOME" in my Property Textfield

    I become the right Text where i have set only for my Nodes at Level 1 up and not for Level 0 -- this is my Home Level

    ??

     

  • Tim 225 posts 690 karma points
    Nov 25, 2009 @ 18:21
    Tim
    0

    Hi,

    Change this line

    <xsl:if test="string($currentPage/ancestor-or-self::node[@level=1]/text()) = ''">

    to

    <xsl:if test="string($currentPage/ancestor-or-self::node[@level=1] [@alias='contentPageTitle'/text()) = ''">

    That should fix it!

  • Wachter Bernd 48 posts 68 karma points
    Nov 26, 2009 @ 08:25
    Wachter Bernd
    0

    Hi Tim,

    No it works not , i become always de and en for my Homepage and not my Text HOME where i set in my Property contentPageTitle..

    Here is my Code from the XSL

    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------

    <?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"
     exclude-result-prefixes="msxml umbraco.library">

    <xsl:output method="html" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage" />

    <!--This sets the level that the nav starts at and tells us if we should recurse through child elements-->
    <xsl:variable name="startDepth" select="/macro/startingLevel" />
    <xsl:variable name="recurse" select="/macro/recurse" />
    <xsl:variable name="selectBranches" select="/macro/selectBranches"></xsl:variable>
    <xsl:variable name="maxMenuDepth" select="/macro/maxMenuDepth"></xsl:variable>
    <xsl:variable name="forceNode" select="/macro/forceNode"></xsl:variable>
    <xsl:variable name="walkChildren" select="/macro/expandChildren"></xsl:variable>
    <xsl:variable name="forceHome" select="/macro/forceHome"></xsl:variable>
    <!--Alternate page title variable in here-->
     
    <!--Styles for the navigation-->
    <xsl:variable name="ulBaseClass" select="/macro/ulBaseClass"></xsl:variable>
    <xsl:variable name="branchClass" select="/macro/branchClass"></xsl:variable>
    <xsl:variable name="selectedClass" select="/macro/selectedClass"></xsl:variable>

    <xsl:variable name="startLevel">
      <xsl:choose>
        <xsl:when test="$startDepth >= 0">
          <xsl:value-of select="$startDepth"/>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$currentPage/@level"/>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:variable>

      <!--This calls first iteration of the navigation, sending the first node at the correct depth found in the ancestors of the current page-->
    <xsl:template match="/">
     
      <xsl:choose>
        <xsl:when test="$forceNode">
          <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById($forceNode)"></xsl:variable>
          <xsl:call-template name="nodeIterator">
            <xsl:with-param name="parentNode" select="$currentNode/ancestor-or-self::node[@level=$startLevel] [string(data [@alias='umbracoNaviHide']) != '1']" />
            <xsl:with-param name="pseudoCurrentPage" select="$currentNode" />
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:variable name="currentNode" select="$currentPage"></xsl:variable>
          <xsl:call-template name="nodeIterator">
            <xsl:with-param name="parentNode" select="$currentNode/ancestor-or-self::node[@level=$startLevel] [string(data [@alias='umbracoNaviHide']) != '1']" />
            <xsl:with-param name="pseudoCurrentPage" select="$currentNode" />
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>

    <xsl:template name="nodeIterator">
        <xsl:param name="parentNode" />
        <xsl:param name="pseudoCurrentPage" />
        <!-- do not show info doc node types-->

      <xsl:variable name="calculatedMenuDepth" select="($parentNode/@level - $startLevel)+1" />

      <ul>

            <xsl:attribute name="class">
              <xsl:choose>
                <xsl:when test="$calculatedMenuDepth = 1">
                  <xsl:value-of select="concat($ulBaseClass, ' lv', $calculatedMenuDepth)" />
                </xsl:when>
                <xsl:when test="$calculatedMenuDepth > 1">
                  <xsl:value-of select="concat('lv', $calculatedMenuDepth)" />
                </xsl:when>
              </xsl:choose>
           </xsl:attribute>

     <xsl:if test="$forceHome = 1 and $calculatedMenuDepth = 1">
              <!-- Create the class for the li element-->
       

    <li>
                <xsl:attribute name="class">
                  <xsl:if test="$currentPage/ancestor-or-self::node[@level=1]/@id = $currentPage/@id">
                    <xsl:value-of select="concat($selectedClass,' ')"/>
                  </xsl:if>
                  <xsl:value-of select="'hasChildren '"/>
                </xsl:attribute>


                <a href="{umbraco.library:NiceUrl($currentPage/ancestor-or-self::node[@level=1]/@id)}">

                  <xsl:attribute name="class">
                    <xsl:if test="$currentPage/ancestor-or-self::node[@level=1]/@id = $currentPage/@id">
                      <xsl:value-of select="concat($selectedClass,' ')"/>
                    </xsl:if>
                  </xsl:attribute>

                  <!--set the innerText for the a element-->
                 
      <xsl:value-of select="$currentPage/ancestor-or-self::node[@level=1] [@alias='contentPageTitle']/text()"/>
                  <xsl:if test="string($currentPage/ancestor-or-self::node[@level=1] [@alias='contentPageTitle']/text()) = ''">
                   <xsl:value-of select="$currentPage/ancestor-or-self::node[@level=1]/@nodeName"/>
                  </xsl:if>
                </a>
              </li>
            </xsl:if>
            <!--End force home-->
           
           
            <!--for each node in the parent node that is not hidden by Umbraco-->
            <xsl:for-each select="$parentNode/node [string(data [@alias='umbracoNaviHide']) != '1']">

              <!--Set the current node id i.e. the node we have looped to not the current page-->
              <xsl:variable name="currentNodeID" select="./@id" />

              <!--Is the node a branch? i.e. are there children and is it in the colletion of ancestor nodes -->
              <xsl:variable name="isBranch">
                <xsl:choose>
                  <xsl:when test="$pseudoCurrentPage/ancestor-or-self::node[@id = $currentNodeID]/child::node">1</xsl:when>
                </xsl:choose>
              </xsl:variable>

              <!--Is the node selected? i.e. is it the same as the currentPage node-->
              <xsl:variable name="isSelected">
                <xsl:choose>
                  <xsl:when test="$pseudoCurrentPage/@id = $currentNodeID">1</xsl:when>
                </xsl:choose>
              </xsl:variable>

              <xsl:variable name="isSelectedBranch">
                <xsl:choose>
                  <xsl:when test="$isBranch = 1 and $selectBranches = 1">1</xsl:when>
                </xsl:choose>
              </xsl:variable>

              <xsl:variable name="hasChildren">
                <xsl:choose>
                  <xsl:when test="./node">1</xsl:when>
                </xsl:choose>
              </xsl:variable>

              <li>
     
                <!-- Create the class for the li element-->
                <xsl:attribute name="class">
                  <xsl:if test="$isSelected = 1"> <xsl:value-of select="concat($selectedClass,' ')"/> </xsl:if>
                  <xsl:if test="$isSelectedBranch = 1"> <xsl:value-of select="concat($branchClass,' ')"/> </xsl:if>
                  <xsl:if test="$hasChildren = 1"><xsl:value-of select="'hasChildren '"/></xsl:if>
                </xsl:attribute>

                <a href="{umbraco.library:NiceUrl(@id)}">
                 
                  <xsl:attribute name="class">
                    <xsl:if test="$isSelected = 1"> <xsl:value-of select="concat($selectedClass,' ')"/> </xsl:if>
                    <xsl:if test="$isSelectedBranch = 1"> <xsl:value-of select="concat($branchClass,' ')"/> </xsl:if>
                  </xsl:attribute>

                  <!--set the innerText for the a element-->
                  <xsl:value-of select="./data[@alias='contentPageTitle']/text()"/>

                 <xsl:if test="string(./data[@alias='contentPageTitle']/text()) = ''"> 
                      <xsl:value-of select="@nodeName"/>
                  </xsl:if>
                </a>

                <!-- if it's a branch recurse through it's children-->
                <xsl:if test="((($isBranch = 1 and $recurse = 1) or ($walkChildren = 1 and $currentPage/descendant-or-self::node[@id = $currentNodeID]/child::node)) and $maxMenuDepth &gt;= $calculatedMenuDepth)">
                  <xsl:call-template name="nodeIterator">
                    <xsl:with-param name="parentNode" select="." />
                    <xsl:with-param name="pseudoCurrentPage" select="$pseudoCurrentPage" />
                  </xsl:call-template>
                </xsl:if>

              </li>

            </xsl:for-each>

          </ul>
      </xsl:template>

    </xsl:stylesheet>

  • Tim 225 posts 690 karma points
    Nov 26, 2009 @ 12:35
    Tim
    0

    Hi

    Fixed - use this XSLT:

    <?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"
    exclude-result-prefixes="msxml umbraco.library">

    <xsl:output method="html" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage" />

    <!--This sets the level that the nav starts at and tells us if we should recurse through child elements-->
    <xsl:variable name="startDepth" select="/macro/startingLevel" />
    <xsl:variable name="recurse" select="/macro/recurse" />
    <xsl:variable name="selectBranches" select="/macro/selectBranches"></xsl:variable>
    <xsl:variable name="maxMenuDepth" select="/macro/maxMenuDepth"></xsl:variable>
    <xsl:variable name="forceNode" select="/macro/forceNode"></xsl:variable>
    <xsl:variable name="walkChildren" select="/macro/expandChildren"></xsl:variable>
    <xsl:variable name="forceHome" select="/macro/forceHome"></xsl:variable>
    <!--Alternate page title variable in here-->

    <!--Styles for the navigation-->
    <xsl:variable name="ulBaseClass" select="/macro/ulBaseClass"></xsl:variable>
    <xsl:variable name="branchClass" select="/macro/branchClass"></xsl:variable>
    <xsl:variable name="selectedClass" select="/macro/selectedClass"></xsl:variable>

    <xsl:variable name="startLevel">
    <xsl:choose>
    <xsl:when test="$startDepth >= 0">
    <xsl:value-of select="$startDepth"/>
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="$currentPage/@level"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>

    <!--This calls first iteration of the navigation, sending the first node at the correct depth found in the ancestors of the current page-->
    <xsl:template match="/">

    <xsl:choose>
    <xsl:when test="$forceNode">
    <xsl:variable name="currentNode" select="umbraco.library:GetXmlNodeById($forceNode)"></xsl:variable>
    <xsl:call-template name="nodeIterator">
    <xsl:with-param name="parentNode" select="$currentNode/ancestor-or-self::node[@level=$startLevel] [string(data [@alias='umbracoNaviHide']) != '1']" />
    <xsl:with-param name="pseudoCurrentPage" select="$currentNode" />
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwise>
    <xsl:variable name="currentNode" select="$currentPage"></xsl:variable>
    <xsl:call-template name="nodeIterator">
    <xsl:with-param name="parentNode" select="$currentNode/ancestor-or-self::node[@level=$startLevel] [string(data [@alias='umbracoNaviHide']) != '1']" />
    <xsl:with-param name="pseudoCurrentPage" select="$currentNode" />
    </xsl:call-template>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    <xsl:template name="nodeIterator">
    <xsl:param name="parentNode" />
    <xsl:param name="pseudoCurrentPage" />
    <!-- do not show info doc node types-->

    <xsl:variable name="calculatedMenuDepth" select="($parentNode/@level - $startLevel)+1" />

    <ul>

    <xsl:attribute name="class">
    <xsl:choose>
    <xsl:when test="$calculatedMenuDepth = 1">
    <xsl:value-of select="concat($ulBaseClass, ' lv', $calculatedMenuDepth)" />
    </xsl:when>
    <xsl:when test="$calculatedMenuDepth > 1">
    <xsl:value-of select="concat('lv', $calculatedMenuDepth)" />
    </xsl:when>
    </xsl:choose>
    </xsl:attribute>

    <xsl:if test="$forceHome = 1 and $calculatedMenuDepth = 1">
    <!-- Create the class for the li element-->


    <li>
    <xsl:attribute name="class">
    <xsl:if test="$currentPage/ancestor-or-self::node[@level=1]/@id = $currentPage/@id">
    <xsl:value-of select="concat($selectedClass,' ')"/>
    </xsl:if>
    <xsl:value-of select="'hasChildren '"/>
    </xsl:attribute>


    <a href="{umbraco.library:NiceUrl($currentPage/ancestor-or-self::node[@level=1]/@id)}">

    <xsl:attribute name="class">
    <xsl:if test="$currentPage/ancestor-or-self::node[@level=1]/@id = $currentPage/@id">
    <xsl:value-of select="concat($selectedClass,' ')"/>
    </xsl:if>
    </xsl:attribute>

    <!--set the innerText for the a element-->

    <xsl:value-of select="$currentPage/ancestor-or-self::node[@level=1]/data [@alias='contentPageTitle']/text()"/>
    <xsl:if test="string($currentPage/ancestor-or-self::node[@level=1]/data [@alias='contentPageTitle']/text()) = ''">
    <xsl:value-of select="$currentPage/ancestor-or-self::node[@level=1]/@nodeName"/>HERE
    </xsl:if>
    </a>
    </li>
    </xsl:if>
    <!--End force home-->


    <!--for each node in the parent node that is not hidden by Umbraco-->
    <xsl:for-each select="$parentNode/node [string(data [@alias='umbracoNaviHide']) != '1']">

    <!--Set the current node id i.e. the node we have looped to not the current page-->
    <xsl:variable name="currentNodeID" select="./@id" />

    <!--Is the node a branch? i.e. are there children and is it in the colletion of ancestor nodes -->
    <xsl:variable name="isBranch">
    <xsl:choose>
    <xsl:when test="$pseudoCurrentPage/ancestor-or-self::node[@id = $currentNodeID]/child::node">1</xsl:when>
    </xsl:choose>
    </xsl:variable>

    <!--Is the node selected? i.e. is it the same as the currentPage node-->
    <xsl:variable name="isSelected">
    <xsl:choose>
    <xsl:when test="$pseudoCurrentPage/@id = $currentNodeID">1</xsl:when>
    </xsl:choose>
    </xsl:variable>

    <xsl:variable name="isSelectedBranch">
    <xsl:choose>
    <xsl:when test="$isBranch = 1 and $selectBranches = 1">1</xsl:when>
    </xsl:choose>
    </xsl:variable>

    <xsl:variable name="hasChildren">
    <xsl:choose>
    <xsl:when test="./node">1</xsl:when>
    </xsl:choose>
    </xsl:variable>

    <li>

    <!-- Create the class for the li element-->
    <xsl:attribute name="class">
    <xsl:if test="$isSelected = 1"> <xsl:value-of select="concat($selectedClass,' ')"/> </xsl:if>
    <xsl:if test="$isSelectedBranch = 1"> <xsl:value-of select="concat($branchClass,' ')"/> </xsl:if>
    <xsl:if test="$hasChildren = 1"><xsl:value-of select="'hasChildren '"/></xsl:if>
    </xsl:attribute>

    <a href="{umbraco.library:NiceUrl(@id)}">

    <xsl:attribute name="class">
    <xsl:if test="$isSelected = 1"> <xsl:value-of select="concat($selectedClass,' ')"/> </xsl:if>
    <xsl:if test="$isSelectedBranch = 1"> <xsl:value-of select="concat($branchClass,' ')"/> </xsl:if>
    </xsl:attribute>

    <!--set the innerText for the a element-->
    <xsl:value-of select="./data[@alias='contentPageTitle']/text()"/>

    <xsl:if test="string(./data[@alias='contentPageTitle']/text()) = ''">
    <xsl:value-of select="@nodeName"/>
    </xsl:if>
    </a>

    <!-- if it's a branch recurse through it's children-->
    <xsl:if test="((($isBranch = 1 and $recurse = 1) or ($walkChildren = 1 and $currentPage/descendant-or-self::node[@id = $currentNodeID]/child::node)) and $maxMenuDepth &gt;= $calculatedMenuDepth)">
    <xsl:call-template name="nodeIterator">
    <xsl:with-param name="parentNode" select="." />
    <xsl:with-param name="pseudoCurrentPage" select="$pseudoCurrentPage" />
    </xsl:call-template>
    </xsl:if>

    </li>

    </xsl:for-each>

    </ul>
    </xsl:template>

    </xsl:stylesheet>

    Tim

  • Wachter Bernd 48 posts 68 karma points
    Nov 26, 2009 @ 14:07
    Wachter Bernd
    0

    Hi Tim,

    Yes it works now perfect !!!!

    Thanks so much

     

     

  • Tim 225 posts 690 karma points
    Nov 26, 2009 @ 14:19
    Tim
    0

    Glad I could help!

    Tim

Please Sign in or register to post replies

Write your reply to:

Draft