Copied to clipboard

Flag this post as spam?

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


  • Jan Molbech 31 posts 76 karma points
    Feb 23, 2012 @ 13:05
    Jan Molbech
    0

    how do i make a navigation show a certain documenttype regardless of level?

    Here is my site structure

    What i am trying to achieve:

    When i am on the "home-page" (level 1 i think) i want my navigation to show "welcome", "Navigation", "Content overview". These are all a documenttype called "startpara". If i navigate to one of these pages (go down one level) i still want the navigation to show these pages.

    If i navigate from "home-page" to one of the other subpages e.g "eSourcing" (which is a documenttype called "modules") i want the navigation to show the subpages of "eSourcing". Again if i navigate to one of these subpages i still want the navigation to show these subpages. 

    I hope that is understandable=:)

    Here is the code i've got.

     

    <?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"/>
    <!-- Input the documenttype you want here -->
    <xsl:variable name="documentTypeAlias" select="'StartPara'"/>
        <xsl:variable name="documentTypeAlias2" select="'Paragraphs'"/>
    <xsl:variable name="cururl" select="umbraco.library:RequestServerVariables('URL')"/>
    <xsl:template match="/">
    <!-- The fun starts here -->
      
       <xsl:choose>
         
         <xsl:when test="$cururl='/home-page.aspx'">
           <div class="SideMenuColor">
            <ul>
         <xsl:for-each select="$currentPage/* [name() = $documentTypeAlias and string(umbracoNaviHide) != '1']">
              
            <li>
              <href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
              </a>
            </li>
          </xsl:for-each>
           </ul>
         </div>
        </xsl:when>
    <xsl:otherwise>
      <div class="SideMenuColorGreen">
      <ul>
      <xsl:for-each select="$currentPage/* [name() = $documentTypeAlias2 and string(umbracoNaviHide) != '1']">
            <li>
              <href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
              </a>
            </li>
          </xsl:for-each>
      </ul>
         </div>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    </xsl:stylesheet>

    This code only works as far as showing the navigation when i am at "home-page" and when i am on one of the pages with the documenttype "modules". 

    As soon as i navigate to one of the subpages the navigation disappears because i go down one level.

    What would be the best way to solved this issue? And please could you show me code examples?

    Cheers.

    Jan Molbech

Please Sign in or register to post replies

Write your reply to:

Draft