Copied to clipboard

Flag this post as spam?

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


  • Johan 95 posts 264 karma points
    Dec 04, 2015 @ 12:23
    Johan
    0

    Hide from navigation

    How do I make it so that menus that are marked as "hide from navigation" gets hidden from the navigation?

    Here is my code:

    <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:Examine="urn:Examine" 
        exclude-result-prefixes="msxml umbraco.library Examine ">
    
    
    <xsl:output method="xml" omit-xml-declaration="yes" />
    
    <xsl:param name="currentPage"/>
    
    <!-- Input the documenttype you want here -->
    <!-- Typically '1' for topnavigtaion and '2' for 2nd level -->
    <!-- Use div elements around this macro combined with css -->
    <!-- for styling the navigation -->
    <xsl:variable name="level" select="1"/>
    
    <xsl:template match="/">
    
          <div class="navbar">
            <div class="navbar-inner">
              <div class="container-fluid">
                  <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <div class="icon">
                      <span class="icon-bar">&nbsp;</span>
                      <span class="icon-bar">&nbsp;</span>
                      <span class="icon-bar">&nbsp;</span>
                    </div>
                  </a>
                <h3> Navigation</h3>
                  <div class="nav-collapse collapse">
                    <ul id="topNavigation" class="nav">
                      <li class="home">
                        <xsl:if test="$currentPage/@id = $currentPage/ancestor-or-self::* [@level=$level]/@id">
                          <xsl:attribute name="class">home current</xsl:attribute>
                        </xsl:if>
                        <a href="/">Home</a>
                      </li>
                      <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
                        <li>
                          <xsl:if test="@id = $currentPage/@id">
                            <xsl:attribute name="class">current</xsl:attribute>
                          </xsl:if>
                          <a class="navigation" href="{umbraco.library:NiceUrl(@id)}">
                            <span>
                              <xsl:value-of select="@nodeName"/>
                            </span>
                          </a>
                        </li>
    
    
                      </xsl:for-each>
                    </ul>
                  </div>
              </div>
            </div>
          </div>
    
        </xsl:template>
    
  • Dennis Aaen 4499 posts 18254 karma points admin hq c-trib
    Dec 04, 2015 @ 12:30
    Dennis Aaen
    101

    Hi Johan,

    If your code is correct, then you should simply add a property on your document type for the texpages with the alias of umbracoNaviHide or any other document types where you want the user to be able to hide some pages.

    You should use the data type of "True/false".

    enter image description here

    Hope this helps,

    /Dennis

  • Johan 95 posts 264 karma points
    Dec 04, 2015 @ 12:39
    Johan
    0

    Thank you Dennis!

Please Sign in or register to post replies

Write your reply to:

Draft