We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 7087
    • 15 Posts
    Hi All,

    Firstly let me say hi, I am, like many others new to Modx, attracted to it following its recent success in the Packt CMS awards. It is fantastic to see such a great product freely available, well written and configurable - well done to all the guys at Modx and of course all the Modx Gurus who continually provide support in these forums.

    That out of the way, I need a little help myself. Now I need to try and be clear and concise. I am trying to build a 2 level horizontal navigation menu. The first level will be all level ’0’ pages on the site, the second level will be different depending on which level ’0’ page you are on. The essence is like this as an example.

    Home | Company | Portfolio | About - (Level 0 Nav)

    Whilst in the Portfolio page, the navigation above is displayed with the Portfolio page current i.e.

    Home | Company | Portfolio | About - (Level 0 Nav)

    Also, the following secondary navigation is displayed as selecting Portfolio takes you to the first page of the Portfolio i.e. Development

    Development | Construction | Design

    Therefore, on the Development page both Navigation bars would look like below, providing visitors with feedback on which page within the portfolio they are on.

    Home | Company | Portfolio | About - (Level 0 Nav)
    Development | Construction | Design

    I have been looking at the Wayfinder snippet and I have to say, I like most am confused. I can create this functionality within CSS and I think that a number of users may also find a wayfinder tutorial for this solution very useful. My biggest problem is that this solution requires two wayfinder entries in the page template. The first wayfinder snippet needs to display ’active’ for the ’Development’ page and at the same time, the other wayfinder snippet needs to display ’active’ for the ’Portfolio’ page even though we are not actually on this page. Most confusing.

    Can anyone lead us through at tutorial of some kind in order to create this. As I progress I intend to post tutorials myself in a bid to aid other users, so let’s all share.

    Good luck to you all and any help would be much appreciated.

    Regards,

    Alan.

      • 7087
      • 15 Posts
      Hi GaneshXL,

      Thanks for the helpful response.

      As a newbie I read your response and a cloud passed over my eyes - in other words - I simply don’t see what I need to do. Also, having looked at the examples, they don’t appear to show both menus as active at any one time as when you click on the sub navigation the page changes. I need to be able to click on the first nav (portfolio link), and for this to show as active i.e. underlined. This link when clicked will take the visitor to the first page of the second nav i.e. Development. This link will then also become active i.e. underlined. Changing to subsequent subnav pages (Construction, Design) results in these links showing as active. All the time, the first nav portfolio link is also active (Hope this all makes sense)

      I really need someone to help me walk through this a step at a time. If someone is willing to do this then I will type up the instructions and publish them as part of a ’Modx Tips and Tricks’ e-book which I will make freely available once compiled. My way of giving back!

      Look forward to your replies.

      Regards,

      Alan.
        • 7231
        • 4,205 Posts
        denspad: this is a tricky menu to get working as you describe (if I understood correctly you are looking for something like this:
        http://www.cssplay.co.uk/menus/simple_dropline.html ). The method that GaneshXL described using two wayfinder calls to build the individual levels is the easiest way to do it but it will be fixed, meaning that only one sub set will show at a time. To get the other sub sets you would need to navigate to that section. So you would not have access to the other sub sets directly.

        The first thing that you need to do is to get familiar with Wayfinder. This is the tool used to generate menus based on the document tree. Muddydogpaws has good documentation for using Wayfinder and all of it’s parameters.

        I think that the menu in the link above can be reproduced with Wayfinder but it will require a bit of effort and I don’t have time to tackle it at the moment.

          [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

          Something is happening here, but you don't know what it is.
          Do you, Mr. Jones? - [bob dylan]
          • 8894
          • 114 Posts
          I think it could be done with only one Wayfinder call, using &hideSubMenus and &activeParentRowTpl.
          It’s a bit late for me (11:00PM) so I can’t try it myself now.
          But my idea is that :

          • Wayfinder will automatically add the "active" class to your level1 item
          • &hideSubMenus=`TRUE` will hide other level0 items’ children
          • by using &activeParentRowTpl, you can add a special class to all parents (and grandparents) of the active item
          So, with the "active" class and the special class you define, you should be able to use CSS to style the whole thing.
          Hope this will help you ...
            • 7087
            • 15 Posts
            Hi Enidan and dev_cw,

            Thank you both for taking the time to respond to this posting.

            dev_cw has got it exactly right. I am trying to reproduce a menu exactly the same as that at http://www.cssplay.co.uk/menus/simple_dropline.html with ’Wayfinder’.
            I have read the Wayfinder documentation but I have to say I am struggling. Is anyone up for the challenge of helping me write a tutorial on this, step by step?
            This is what I feel less technical people really need and I also feel is a little lacking for the ModX product. Compiling such a document would say users of the system hours in searching through forums.

            I dont really understand the comment "The method that GaneshXL described using two wayfinder calls to build the individual levels is the easiest way to do it but it will be fixed, meaning that only one sub set will show at a time. To get the other sub sets you would need to navigate to that section. So you would not have access to the other sub sets directly." so I don’t know if this is a problem . However, to get to the other sub-sets by navigating to that section sounds perfectly normal to me. My issue/problem was always how to show the parent and child menus with two active links at the same time when we were not actually on the parent page.

            I guess the next stage is to walk through this a step at a time, can anyone help me do this?

            Many thanks for all your help so far.

            Regards,

            Alan.
              • 7231
              • 4,205 Posts
              I dont really understand the comment
              By using two wayfinder calls the second level will only be active when in that section, not like the menu in the link I showed since the other sub levels are always available.

              I think it could be done with only one Wayfinder call
              I think it can as well and will make a good config file for Wayfinder. But it will require a bit more effort than you described. I started to break it down at one point for another post that needed the same style menu but gave up after a few tries.didn’t have time to really get into it.
                [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                Something is happening here, but you don't know what it is.
                Do you, Mr. Jones? - [bob dylan]
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                We’re talking about a basic drop-line menu, like the in Manager, right?
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 7231
                  • 4,205 Posts
                  We’re talking about a basic drop-line menu, like the in Manager, right?
                  Yes, like in the manager with the sticky current sub section.

                  I was able to almost reproduce the CSSPlay menu in the link above but it needs more options than I can get with wayfinder since it has a different structure. I will gather my progress and post it in a few minutes in case anyone wishes to follow through with it.
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don't know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 7231
                    • 4,205 Posts
                    Ok here is what I got:

                    outerTpl:
                    <div id="nav">
                        [+wf.wrapper+]
                    </div>


                    rowTpl:
                    <ul class="select">
                          <li>
                            <a href="[+wf.link+]">[+wf.linktext+]<!--[if IE 7]><!--></a><!--<![endif]--><!--[if lte IE 6]><table><tr><td><![endif]-->
                                  [+wf.wrapper+]
                          </li>
                    </ul>


                    innerTpl:
                    <ul class="sub">
                        [+wf.wrapper+]
                    </ul><!--[if lte IE 6]></td></tr></table></a><![endif]-->


                    innerRowTpl:
                    <li><a href="[+wf.link+]">[+wf.linktext+]</a></li>


                    The call:
                    [[Wayfinder? &startId=`0` &level=`2` &outerTpl=`outerTpl` &innerTpl=`innerTpl` &rowTpl=`rowTpl` &innerRowTpl=`innerRowTpl` &cssTpl=`cssplay_css` ]]


                    The css chunk:
                    <style type="text/css">
                    /* ================================================================ 
                    This copyright notice must be untouched at all times.
                    
                    The original version of this stylesheet and the associated (x)html
                    is available at http://www.cssplay.co.uk/menus/simple_dropline.html
                    Copyright (c) 2005-2007 Stu Nicholls. All rights reserved.
                    This stylesheet and the associated (x)html may be modified in any 
                    way to fit your requirements.
                    =================================================================== */
                    /* for this demo only */
                    #nav {margin:20px 0 80px 0;}
                    
                    /* the styling */
                    #nav {width:750px; height:20px; background:#000; position:relative;}
                    
                    #nav .select, #nav .current {margin:0; padding:0; list-style:none;}
                    
                    #nav li {display:inline; margin:0; padding:0; height:auto;}
                    
                    #nav .select a,
                    #nav .current a {display:block; height:20px; float:left; background:#000; padding:0 10px 0 10px; text-decoration:none; font-size:12px; line-height:20px; white-space:nowrap; border-right:1px solid #fff; color:#fff;}
                    * html #nav .select a, * html #nav .current a {width:1px; height:21px;}
                    
                    
                    #nav .select a:hover, 
                    #nav .select li:hover a {background:#888; cursor:pointer; color:#ff0;}
                    
                    #nav .sub {display:none;}
                    
                    /* for IE5.5 and IE6 only */
                    #nav table {position:absolute; border-collapse:collapse; left:0; top:0;}
                    
                    #nav .current a {background:#666; color:#ff0;}
                    
                    
                    #nav .sub li a:hover, 
                    #nav .select a:hover .sub li a:hover, 
                    #nav .select li:hover .sub li a:hover {background:#888; color:#ff0;}
                    
                    #nav .sub_active .current_sub a, 
                    #nav .sub_active a:hover {background:#666; color:#ff0;}
                    
                    #nav .select li a:hover .sub, 
                    #nav .select li:hover .sub {display:block; position:absolute; width:750px; top:20px; left:0; background:#888; margin-top:0; padding:0; z-index:100; color:#fff; font-size:11px;}
                    
                    #nav .sub, #nav .sub_active {margin:0; padding:0; list-style:none;}
                    
                    #nav .sub_active {display:block; position:absolute; width:750px; top:20px; left:0; background:#666; margin-top:0; padding:0; z-index:10;}
                    * html #nav .sub_active, * html #nav .select a:hover .sub {z-index:-1; margin-top:0; margin-t\op:1px;}
                    
                    #nav .sub_active a {height:21px; text-decoration:none; line-height:20px; white-space:nowrap; display:block; float:left; background:#666; padding:5px 10px 10px 10px; margin:0; font-size:12px; white-space:nowrap; border:0; color:#fff;}
                    
                    #nav .select a:hover .sub li a, 
                    #nav .select li:hover .sub li a {display:block; background:#888; padding:5px 10px 10px 10px; margin:0; white-space:nowrap; border:0; color:#fff; font-size:12px;}
                    </style>


                    Up to here it is working, this will give the basic dropline menu.

                    I was able to get the current parent to work as well with the activeParentRowTpl but here it started to breakdown:
                        <ul class="current">
                          <li><a href="[+wf.link+]">[+wf.linktext+]</a></li>
                        </ul>
                    [+wf.wrapper+]


                    But at this point the current sub will not work. The catch is that the menu uses two structures, in the normal state the subs are nested <ul> but in the active state they are independent <ul> so you would need a innerActiveParent or something like that ( I may have overlooked something or not be thinking outside or inside the box). There may be a way to use a combination of tpl and classes to get this to work but I am stumped at this point. Hope someone can follow up from this point shocked
                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don&#39;t know what it is.
                      Do you, Mr. Jones? - [bob dylan]