Copied to clipboard

Flag this post as spam?

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


  • Matthew 1 post 21 karma points
    Nov 17, 2011 @ 19:04
    Matthew
    0

    Seperate page needs navigation

    To start, I'm sorry if this is not the correct thread.

     

    I just recently started using Umbraco, about 2 days ago and I'm working on a project, normally written from scratch wouldn't take long but they needed to use a CMS so the company decided on Umbraco. So far I like it a lot. But I've ran into a problem I'm sure can be fixed.

     

    On the homepage there is a navigation at the top with Home, Wine, Wine Maker, etc, links in general.

    Using:

    <umbraco:macro id="Macro1" alias="umbTopNavigation" runat="server"></umbraco:macro>

    On a seperate page such as 'Wine' I need another navigation directly under that topNavigation, but only on that one page. The sub-navigation will have different kinds of wines for customers to choose from.

     

    I've reviewed some video tutorials on YouTube as well as the ones on the site and I've learned a lot, but I'm not sure how I would go about inserting another navigation and I would need it directly under the topNavigation, if I was able to get the subNavigation on just the wines page would I be able to style it and put under the topNavigation so that's it's not just part of the 'page'? Like when you create a blog page the blog is in the page area where I wouldn't need it really, I would need it somewhat attached the topNavigation which might be outside of the content tag, if I can style it though no problem.

     

    I just need help setting up a subnavigation for one page, basically, and be able to style it.

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Nov 17, 2011 @ 23:54
    Jan Skovgaard
    0

    Hi Matthew and welcome to our :)

    In order to make a subnaviation that should just be shown on the "Wine" page you can for instance create a XSLT based macro to return the subnodes of Wine.

    Since I don't know much about the document types you're using and what the document type alias for your textpage document type is I'll just show you a basic dummy example.

    <xsl:template match="/">

       <xsl:if test="$currentPage/@id ='1050'>
            <ul>
               <xsl:apply-templates select="$currentPage/ancestor-or-self::*[@isDoc][@level = 1]/*[@isDoc]" />
            </ul>
       </xsl:if>

    </xsl:template>

    <xsl:template match="Textpage">

    <li>
         <a href="umbraco.library:NiceUrl(@id)">
             <xsl:value-of select="@nodeName" />
         </a>
    </li>

    </xsl:template>

    Please bear in mind that this example above is made from the top of my mind, so maybe there is something I have overlooked - don't have access to Umbraco on this one :)

    But what it's intended to do is to match all documents on level 2 that has document alias of "Textpage". Please be aware that document type aliases are saved with the first letter being in upper-case in the XML data layer. So if you're trying to match "textpage" nothing will get returned. When we're applying the template we make a check on the id of the current page - here you should place the id of the "Wine" page to make sure the macro is only rendered on the wine page. You can see the nodeid by going to the "properties" tab in the content section or you can simply hover over the "Wine" page in the content tree and look in the lower left corner of the browser where you'll also see the nodeid.

    You can create this macro by going to the "developer" section within the umbraco backoffice and right click the "xslt" folder and select "create" in the context menu. In the window that appears you can give the macro a name like "subNavigation" and then make sure that the "create macro" checkmark is set and hit "create".

    Copy in the code above and hit save.

    Now you can go to the template section in the umbraco backoffice and select the macro on the template an place it beneath the umbTopNaviation that you showed above. If you need to group the html output into a <div> you can just do it like this

    <div id="nav">
    <umbraco:macro alias="umbTopNavigation" runat="server"></umbraco:macro>
    <umbraco:macro alias="subNavigation" runat="server"></umbraco:macro>
    </div>

    I hope this helps - If you're in doubt about anything just feel free to ask since we're a bunch of friendly people who love to help each other out no matter the skill level :)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft