We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37437
    • 147 Posts
    I’m running the latest version of Revolution, and I am trying to construct a 3-tiered, vertically-aligned navigational menu with Wayfinder. Unfortunately, I’m running into a number of persistent and counterintuitive issues:

    1. I have created an Outer template
    <ul id="topnav" [[+wf.classes]]>[[+wf.wrapper]]</ul>
    and assigned CSS attributes to the ’topnav’ ID in the CSS associated with the menu. The attributes are being picked up by the menu, but they do not apply to the topmost menu items (only the second and third level items). This absolutely baffles me because I not only thought that the Outer template was used to encase the entire menu, but when I look at the source code for the output, the topmost items do appear to fall within the range of this ID. Why am I unable to ’grab’ and format the items at the top level of my menu with the Outer template?

    2. Why is it that when I include the ’&selfClass ’ parameter in the Wayfinder call, the attributes assigned to the class to not only affect the active item, but also affect its parents all the way up the chain? Basically, it seems as though the ’&selfClass’ is behaving like the ’&hereClass’ parameter.

    3. My menu is embedded within a div and I have been very careful to zero out all padding and margins. Nevertheless, I can’t seem to get the menu to sit left-aligned within the div unless I assign negative left margin to the Outer list items. (This also relates to question 1 and the problem I am having in trying to ’grab’ the ENTIRE menu. When I assign a negative left margin, it only ends up affecting the second and third tier items in the menu, and not the top level of the menu.) Anyway, why is it that, by default, the menu ends up sitting towards the center of the main div even though I have really done my homework in terms of zeroing out margins and padding? Here is the CSS for the menu’s primary ul:

    #outer ul{
    display: block;
    width: 100%;
    border: 1px solid green;
    margin: 0px;
    padding: 0px;
    text-indent: 0%;
    }


    Thanks for any help you might be able to offer. Struggling with Wayfinder has actually taught me a lot. I am ready to finally resolve these issues though.
      • 33968
      • 863 Posts
      Hi there, regarding point 2 - I haven’t experienced that but it might be a bug. The selfClass attribute should only be applied to the current item and that’s how it worked when I tried to replicate your issue.

      Points 1 and 3 are purely CSS issues and nothing to do with Wayfinder or MODx. First thing that comes to mind is you might be referencing the menu items like [tt]#topnav ul { }[/tt] instead of [tt]#topnav { }[/tt]. But if you post your menu html as rendered by MODx and also your css styles I can have a look through it. If you can link to your test site even better...
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Might that [[+wf.classes]] placeholder in the outerTpl be causing some problems? Since that tpl only applies to the outermost <ul> ... </ul> tags, is it really necessary?
          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
          • 22427
          • 793 Posts
          you might be referencing the menu items like #topnav ul { } instead of #topnav { }
          - or, even better, [tt]ul#topnav { }[/tt]

          Might that [[+wf.classes]] placeholder in the outerTpl be causing some problems? Since that tpl only applies to the outermost <ul> ... </ul> tags, is it really necessary?

          Here an explanation how I understand it:

          If you did not define your own [tt]&outerTpl[/tt] , WF as default takes the following:
          <ul [[+wf.classes]]>[[+wf.wrapper]]</ul>


          So the question arises: How does WF know by which classes it has to replace the placeholder [tt][[+wf.classes]][/tt] ?

          Answer: All about classes is in the CSS rules (which preferably are written in an own CSS file). Hence WF is looking for a style definition for an unordered list and finds f.e. this:
          ul.mymenu {
          ....
          }
          

          So WF will create the output
          <ul class="mymenu"> .... </ul>


          But what about the case that you have various classes for [tt]ul[/tt] elements in your CSS, e.g.
          ul.firstclass {
          ....
          }
          ul.secondclass {
          ....
          }
          

          and f.e. it’s just the second which refers to the menu to be created by the WF call?

          Well, for just that purpose there exists the parameter [tt]&outerClass[/tt] .
          In our example you have to add [tt]&outerClass=`secondclass`[/tt] to the WF call, and as a consequence WF "knows" that it has to style the menu using the rule for [tt]ul.secondclass[/tt] .


            • 37437
            • 147 Posts
            I want to thank you all for making such useful observations and suggestions. I’m definitely making headway, although I’m not quite out of the woods yet.

            As Lucas remarked, I pulled the ’ul’ out of my CSS, and bingo, I was able to grab and realign all of the items in my menu. I’m glad that this worked, however it remains a bit counterintuitive to me that I would have to remove the ’ul’ in order to grab the entire menu: after all, even the top level items in the menu are within the main ’ul’ tags.

            <div id="menu">
            <ul id="topnav"><li class="first level1 active"><a href="http://mysite.com/" title="Home" >Home</a></li>
            <li class="level1"><a href="index.php?id=2" title="Practice Areas" >Practice Areas</a><ul id="topnav"><li class="first level2"><a href="index.php?id=3" title="Monitoring Unobservable Behavior" >Monitoring Unobservable Behavior</a><ul id="topnav"><li class="first level3"><a href="index.php?id=4" title="Hidden Populations" >Hidden Populations</a></li>
            
            <li class="level3"><a href="index.php?id=7" title="Prescription Drug Abuse" >Prescription Drug Abuse</a></li>
            <li class="level3"><a href="index.php?id=8" title="Intelligence Gathering" >Intelligence Gathering</a></li>
            <li class="last level3"><a href="index.php?id=9" title="Custom Applications" >Custom Applications</a></li>
            </ul></li>
            <li class="last level2"><a href="index.php?id=5" title="Managing Organizational Change" >Managing Organizational Change</a><ul id="topnav"><li class="first level3"><a href="index.php?id=10" title="Strategic Planning" >Strategic Planning</a></li>
            <li class="level3"><a href="index.php?id=11" title="Performance Management" >Performance Management</a></li>
            <li class="last level3"><a href="index.php?id=12" title="Custom Applications" >Custom Applications</a></li>
            </ul></li>
            </ul></li>
            <li class="level1"><a href="index.php?id=6" title="Principles" >Principles</a></li>
            
            <li class="last level1"><a href="index.php?id=13" title="Contact" >Contact</a></li>
            </ul>
            </div>
            


            I also followed Susan’s suggestion and removed the [[+wf.classes]] placeholder from my Outer template. As the HTML output displays, Wayfinder still often adds multiple classes (’first’, ’active’, etc.) to the output by default, and I’m not sure if this is somehow interfering with my attempts to control the list items by referencing them based on their level. Here is my current (and very stripped down) Outer template, as well as my Wayfinder call:

            <ul id="topnav">[[+wf.wrapper]]</ul>

            [[!Wayfinder? &startId=`0` &outerTpl=`outer` &levelClass=`level` &hereClass=`here` &cssTpl=`menucss`]]


            Finally, as mentioned in my initial posting, I can’t seem to get the ’&hereClass’ to work properly. I certainly hope this is not a bug as Lucas suggested, since I absolutely need to assign a unique style to the currently active document. Here is my CSS. Please note that none of the ’here’ class attributes get represented in the output at all at this point:

            #topnav {
            display: block;
            width: 100%;
            margin: 0px 0px 0px 0px;
            padding: 0px;
            text-indent: 0%;
            list-style-type: none;
            }
            
            a.level1:link {font-size: 13px; line-height: 26px; color: #000000; text-decoration: none; list-style-type:square;}
            a.level1:hover {font-size: 13px; line-height: 26px; color: #CD3700; text-decoration: none; margin-left: 4px; list-style-type:square;}
            
            a.level2:link {font-size: 13px; line-height: 20px; color: #000000; text-decoration: none; list-style-type:square; margin-left: 8px; }
            a.level2:hover {font-size: 13px; line-height: 20px; color: #CD3700; text-decoration: none; margin-left: 12px; list-style-type:square;}
            
            a.level3:link {font-size: 13px; line-height: 16px; color: #000000; text-decoration: none; margin-left: 16px; list-style-type:square;}
            a.level3:hover {font-size: 13px; line-height: 16px; color: #CD3700; text-decoration: none; margin-left: 20px; list-style-type:square;}
            
            a.here:link:{color: red}
            
            


            No doubt, a lot (if not all) of these problems have roots in CSS. Any additional suggestions would be greatly appreciated. Thanks so much.
              • 22427
              • 793 Posts
              The [tt]id [/tt] for an element has to be unique - in your code you have [tt]<ul id="topnav">[/tt] more than once. You should change this [tt]id[/tt] to a [tt]class[/tt] .
                • 22427
                • 793 Posts
                The parameter [tt]&hereClass[/tt] will appear in the [tt][[+wf.classes]][/tt] placeholder of the row template, which by default is
                <li [+wf.id+] [+wf.classes+] >
                <a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]>[+wf.linktext+]</a>
                [+wf.wrapper+]
                </li>

                So you have to assign your class [tt]here[/tt] not to the [tt]<a>[/tt] element, but to the [tt]<li>[/tt] element, like this:
                li.here a:link {color: red;}

                By the way, you had a superfluous colon after [tt]link[/tt] ,
                a.here:link:{color: red}
                what might have left this rule ignored anyway.
                  • 22427
                  • 793 Posts
                  One more hint, from the documentation (I changed the placeholder to Revo syntax):
                  http://muddydogpaws.com/development/wayfinder/parameters.html
                  The outerTpl template is used as the outer most wrapper for the generated ouput. All documents and folders will be processed and inserted into the [[+wf.wrapper]] placeholder. If no innerTpl is specified the outerTpl is used when creating submenus.
                  The innerTpl template is used as a wrapper for each submenu. If no innerTpl is specified the outerTpl is used in its place. Each item processed in the submenu will be inserted into the placeholder [[+wf.wrapper]].
                  So if you want to style the submenu [tt]ul[/tt] lists differently from the outermost one, you have to use the parameter [tt]&innerTpl[/tt] .
                    • 33968
                    • 863 Posts
                    Quote from: marconi at Jul 17, 2011, 01:20 PM

                    As Lucas remarked, I pulled the ’ul’ out of my CSS, and bingo, I was able to grab and realign all of the items in my menu. I’m glad that this worked, however it remains a bit counterintuitive to me that I would have to remove the ’ul’ in order to grab the entire menu: after all, even the top level items in the menu are within the main ’ul’ tags.
                    Actually that’s quite logical.


                    • When you specify [tt]#topnav ul[/tt], you are targeting all <ul> elements inside the container with id of ’topnav’.
                    • [tt]#topnav[/tt] would target only the container with id ’topnav’, but remember that child elements inherit the parent’s styles.
                    If you’ve followed ottogal’s suggestions I think you’ll find everything is working smiley
                      • 37437
                      • 147 Posts
                      Thanks again folks. Things are better, although some issues remain. What confuses me is this: Since I use the ’&levelClass’ parameter, all of the individual menu levels have a unique class assignment (level1, level2, etc.). Why, then, must I bother with additional templates, such as the Inner template? If the output is already giving me unique classes for each level, shouldn’t I be able to just jump in to my CSS and style those levels by creating desired declarations for the links at each level?