Copied to clipboard

Flag this post as spam?

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


  • praveen 113 posts 164 karma points
    Jul 20, 2012 @ 04:17
    praveen
    0

    Top menu

    Hi

    I have installed 4.7.2 and I need some example XSLT to do the Top Menu

     

    Site is as follows

    > Home

    > Products

    > Services

    > Contact Us

     

    Many thanks for your help in advance

    Kind Regards

  • Adrian Alexa 50 posts 100 karma points
    Jul 20, 2012 @ 07:32
    Adrian Alexa
    0

    This code might help you, however I am looking right now for more functionalities

     

    <?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="xml" omit-xml-declaration="yes" />

        <xsl:param name="currentPage"/>

        <!-- Input the documenttype you want here -->
        <xsl:variable name="level" select="1"/>

        <xsl:template match="/">

            <ul id="topNavigation">
                <li class="home topNavigLi has_submenu">
                    <xsl:if test="$currentPage/@id = $currentPage/ancestor-or-self::* [@level=$level]/@id">
                        <xsl:attribute name="class">home current topNavigLi has_submenu</xsl:attribute>
                    </xsl:if>
                    <a href="/" style="width:200px;">About Patient Direct</a>
                    <ul class="submenu">
                        <li class="submenu_first">
                            <div class="item">
                                <a href="#">Program Coverage</a>
                            </div>
                        </li>
                        <li class="submenu_middle">
                            <div class="item">
                                <a href="#">Eligibility</a>
                            </div>
                        </li>
                        <li class="submenu_middle">
                            <div class="item">
                                <a href="#">Terms and Conditions</a>
                            </div>
                        </li>
                        <li class="submenu_middle">
                            <div class="item">
                                <a href="#">Frequently Asked Questions</a>
                            </div>
                        </li>
                        <li class="submenu_last">
                            <a href="#">Brochure</a>
                        </li>
                    </ul>
                </li>
                <li class="home separator">
                </li>
                <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
                    <li>
                        <xsl:attribute name="class">
                            topNavigLi
                            page<xsl:number value="position()" format="1" />
                          <xsl:if test="@nodeName='Network' ">
                                       has_submenu network
                                      </xsl:if>     
                        </xsl:attribute>
                        <xsl:if test="@id = $currentPage/@id">
                            <xsl:attribute name="class">
                                current topNavigLi
                                page<xsl:number value="position()" format="1" />
                            </xsl:attribute>
                        </xsl:if>
                        <xsl:if test="position() = last()">
                            <xsl:attribute name="class">
                                last topNavigLi
                                page<xsl:number value="position()" format="1" />
                            </xsl:attribute>
                        </xsl:if>

                        <xsl:if test="@id = $currentPage/@id and position() = last()">
                            <xsl:attribute name="class">
                                current last topNavigLi
                                page<xsl:number value="position()" format="1" />
                            </xsl:attribute>
                        </xsl:if>

                        <xsl:choose>
                            <xsl:when test="name() = 'Link'">
                                <a class="navigation" href="{current()/linkUrl}" target="_blank">
                                    <xsl:attribute name="class">last                              
                                      </xsl:attribute>
                                    <xsl:value-of select="@nodeName" />

                                </a>
                             
                            </xsl:when>
                           
                            <xsl:otherwise>
                                <a class="navigation" href="{umbraco.library:NiceUrl(@id)}">
                                    <xsl:value-of select="@nodeName" />
                                </a>
                                <xsl:if test="@nodeName='Network' ">
                                  <ul class="submenu">
                                    <li class="submenu_first">
                                        <div class="item">
                                            <a href="#">About the Patient Direct Network</a>
                                        </div>
                                    </li>
                                   
                                    <li class="submenu_last">
                                        <a href="#">Dentist Search</a>
                                    </li>
                                </ul>
                              </xsl:if>
                            </xsl:otherwise>
                        </xsl:choose>
                    </li>
                  <xsl:if test="position()!=last() ">
                    <li>
                       <xsl:attribute name="class">
                        
                            separator
                            page<xsl:number value="position()" format="1" />

                        </xsl:attribute>
                    </li>
                  </xsl:if>
                </xsl:for-each>
            </ul>

        </xsl:template>

    </xsl:stylesheet>

  • Fuji Kusaka 2203 posts 4220 karma points
    Jul 20, 2012 @ 08:09
    Fuji Kusaka
    0

    Hi Praveen,

    What you can do is 

    <xsl:variable name="level" select="1"/>

    <xsl:template match="/">
    <ul>
    <xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc][not(umbracoNaviHide = 1)]">
      <li>
        <href="{umbraco.library:NiceUrl(@id)}">
          <xsl:value-of select="@nodeName"/>
        </a>
      </li>
    </xsl:for-each>
    </ul>

    Remember to add your other pages Products, Services and Contact Us on a different level.

    - Content
    -- Home 
    --- Products
    --- Services 
    --- Contact Us

    Hope this helps

  • Adrian Alexa 50 posts 100 karma points
    Jul 20, 2012 @ 08:40
    Adrian Alexa
    0
Please Sign in or register to post replies

Write your reply to:

Draft