Copied to clipboard

Flag this post as spam?

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


  • Joe 21 posts 41 karma points
    Feb 08, 2011 @ 01:20
    Joe
    0

    Secondary Navigation - Folder Setup Issue

    Hello,


    I am starting to get comfortable with umbraco, but I am stuck trying to fix some mistakes of a previous web designer.

    So, the problem I have is that instead of making a root folder, they made a root page, with all the secondary pages below that page, and they coded the navigation to accommodate that folder structure.  I am just having trouble with the logic behind node numbering with this setup. Here are some pictures to better explain.

    Here is the code for our primary navigation macro right now:

    <?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 -->
    <!-- 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="/">

    <!-- The fun starts here -->

    <!--xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']"-->
    <xsl:for-each select="umbraco.library:GetXmlNodeById(1045)/node [string(data [@alias='umbracoNaviHide']) != '1']">
            <a href="{umbraco.library:NiceUrl(@id)}" class="navOff">
                <xsl:choose>
                    <xsl:when test="$currentPage/ancestor-or-self::node/@id = current()/@id">
                        <xsl:attribute name="class">navOn</xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:attribute name="class">navOff</xsl:attribute>
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:value-of select="@nodeName"/>
            </a>
    <!-- Secondary Navigation Tests Here -->


    </xsl:for-each>


    </xsl:template>

    </xsl:stylesheet>

    This code renders out like this:

    WHAT I NEED is for the second level page titles (the pages that are below Software, Applications, Related Products, etc) to show up as a <ul> beneath each top level link. (Right now, there is no secondary navigation)  The problem is that for Home, I will see a repeated list of the links that you see in the image above when I use the pre-written secondary nav macro that umbraco supplies. Any ideas for what the easiest fix for this would be?

     

    Thanks much!

     

    _Joe

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Feb 08, 2011 @ 07:23
    Jan Skovgaard
    0

    Hi Joe

    The hardcoded nodeid that is being used, 1045, is probably the id of the "home" node. You can see the ID of a node by holding the mouse over it and look in the lower left corner of the browser.

    I think what you need to do is scratch the above navigation and create a new one based on the predefined "sitemap.xslt", which is possible to choose when creating a new XSLT macro in the developer section. This recursively travels through the nodes and creates the structure you're talking about.

    There is a variable in it where you can specify how deep it should go.

    I hope this makes sense :)

    /Jan

  • Joe 21 posts 41 karma points
    Feb 08, 2011 @ 16:51
    Joe
    0

    So, I would have to rearrange the folder structure then, correct?

    _Joe

  • Joe 21 posts 41 karma points
    Feb 08, 2011 @ 17:26
    Joe
    0

    I realized that I wasn't as clear as I should have been in my original post. When I click on each top level link in my current nav setup, I would like a <ul> to appear beneath that link, each item in that <ul> being a secondary page link. So, the nav setup would have to be dynamically coded. I don't just want a static list of all the secondary links beneath each top level link - that would be too cluttered.

    Thanks!

     

    _Joe

Please Sign in or register to post replies

Write your reply to:

Draft