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 14, 2012 @ 21:17
    Jan Molbech
    0

    navigation disappears on subpage

    i have a side navigation that is based on a certain documenttype on my site but whenever i click (navigate to) one of the links in the navigation, the navigation disappears. Below is my xslt code.

     

    <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>
              <a 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>
              <a 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>

     

    I expect it to remain visible because i use documenttypes and not levels. Why does it disappear?

     

     

  • Nigel Wilson 944 posts 2076 karma points
    Feb 14, 2012 @ 22:29
    Nigel Wilson
    0

    Hi Jan

    When clicking a link in the navigation it would appear you are going down a level within the site tree ($currentPage/*)

    So when your page loads the navigation is looking for sub pages below it. 

    Are you wanting the navigation to display a fixed set of links when you are within a section of your site ?

    If so your xslt should be changed to soemthing along the lines of

    $currentPage/ancestor-or-self[@IsDoc and level() = 2]/*[name() = $documentTypeAlias2 and string(umbracoNaviHide) != '1']

    The above is off the top of my (bald) head so is hopefully correct. The level number will be determined by the structure of yuor site and what level you are wanting displayed, so '2' may not be correct.

    Hope this helps.

    Nigel

     

     

  • Jan Molbech 31 posts 76 karma points
    Feb 15, 2012 @ 09:05
    Jan Molbech
    0

    Well, what i want it to do is to look for the specific documenttype on the same level or levels above it. 

  • Jan Molbech 31 posts 76 karma points
    Feb 15, 2012 @ 20:35
    Jan Molbech
    0

    I've just realized that what i've been trying to do wont work. This is the structure of my site.

     

    When i am on the home page (lvl 1 i think) i want a side navi to show the three pages at the bottom. They are of the doc type "startPara". Whenever i navigate to one of these pages, the navigation still has to show these pages.

    Whenever i navigate to e.g. "eSourcing" (this is a different doctype) the sidenavigation has to change and show the subpages, in this case "content" and "content II". Again if i navigate to "content" or "content II" i still want these pages to be showned in the sidenavigation.

    How do i acomplice this?

    If i navigate to "Welcome". What level is this if home page is lvl 1? 

  • Jan Molbech 31 posts 76 karma points
    Feb 16, 2012 @ 00:37
    Jan Molbech
    0

    I have been looking at this http://our.umbraco.org/wiki/reference/xslt/xpath-axes-and-their-shortcuts

    and from what i can see here it is impossible to go up one level at get all the nodes on that lvl.

    Please tell this isn't so.

  • Jan Molbech 31 posts 76 karma points
    Feb 16, 2012 @ 10:17
    Jan Molbech
    0

    Ok, i have tried a different approach. As you can see from the below code i am now trying to check for documenttypes to determine where to start to generate the navigation, but since im not very good at xslt it doesn't work. 

    Here is what i want it to do:

    situation one: Display all nodes of the type "startPara" in navigation when im on the /home-page.apsx. This works=:)

    situation two: When navigated to one of the pages of the startPara documenttype, go up one level and display all nodes in navigation of the type startPara. This doesn't work. The navigation disappears.

    situation three: When i have navigated to a page of the documenttype "modules" (these are displayed in another navigation) i want the navigation to show all subpages to this Module node of the documenttype "paragraphs" This doesnt work either.

    situation four: When navigated to a subpage of the "paragraph" type i still want the navigation to display the navigation from situation three.

     

    <xsl:param name="currentPage"/>
     
    <!-- Input the documenttype you want here -->
        <xsl:variable name="level" select="1"/>
    <xsl:variable name="documentTypeAlias" select="'StartPara'"/>
        <xsl:variable name="documentTypeAlias2" select="'Paragraphs'"/>
    <xsl:variable name="cururl" select="umbraco.library:RequestServerVariables('URL')"/>
    <xsl:variable name="count" select="count($currentPage/child::* [@isDoc and string(umbracoNaviHide) != '1'])"/>
    <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>
              <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
              </a>
            </li>
          </xsl:for-each>
           </ul>
         </div>
        </xsl:when>
            <xsl:when test="local-name($currentPage)='startPara'">
         <div class="SideMenuColor">
            <ul>
         <xsl:for-each select="$currentPage/parent::*[@isDoc]/* [name() = $documentTypeAlias and string(umbracoNaviHide) != '1']">

              

            <li>
              <a href="{umbraco.library:NiceUrl(@id)}">
                <xsl:value-of select="@nodeName"/>
              </a>
            </li>
          </xsl:for-each>
           </ul>
         </div>
        </xsl:when>
            <xsl:when test="local-name($currentPage)='modules'">
               <div class="SideMenuColorGreen">
      <ul>
      <xsl:for-each select="$currentPage/* [name() = $documentTypeAlias2 and string(umbracoNaviHide) != '1']">
            <li>
              <a 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/parent::* [name() = $documentTypeAlias2 and string(umbracoNaviHide) != '1']">
            <li>
              <a 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>

    (hmm, this is strange. It isnt possible to format my text as "code" anymore)

    Im pretty lost at the moment. I hope someone is able to help.

Please Sign in or register to post replies

Write your reply to:

Draft