We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 19613
    • 70 Posts
    Hi
    I have a sample ’mega-menu’ that I am re-working from an article and I have been playing with it to see if it can/will work in Modx.

    It works fine as ul/li in a hand coded page but my query is whether it can be built dynamically via Modx/Wayfinder?

    My sample page can be seen here >> http://www.creativeinjection.com/megamenutest.html#

    I have built CSS based wayfinder dropdowns etc before with any issues, however, what confuses/concerns me at the moment is how to get the non linked headers and divs etc inside the menu dropdown (The h2 and h3 tags to be more precise) as shown in the code below.

     <li class="mega">
              <h2>
                <a href="#">Logo Design</a>
              </h2>
              <div>
                <h3>
                  Logo design
                </h3>
                <p>
                  <a href="#">Corporate</a>, <a href="#">Small Business</a>, <a href="#">Clubs & Societies</a>, <a href="#">More...</a>
                </p>
                <h3>
                  Branding
                </h3>
                <p>
                  <a href="#">Naming Your Product</a>, <a href="#">Marketing</a>, <a href="#">More...</a>            </p>
                <h3>
                  Clearance!
                </h3>
                <p>
                  40% off all design books this weekend only. <a href="#">Don't miss out!</a>
                </p><a href="#" class="more">More stuff for Branding...</a>
              </div>
            </li>


    I hope I have explained this properly... any questions/hints/help would be great grin

    If I can get it to work I intend to put together a deep/full tutorial including credit any ideas etc to help anyone else... but i need some nudges in the right direction.

    P.s I think I should of put this in the sub forum (sorry) but i don’t know how to move it.
      • 16183
      • 1,390 Posts
      Hi,

      1. What’s the relationship between your documents? e.g. are "Corporate", "Small Business", "Clubs & Societies" and "More..." children of "Logo Design" or not? - I mean the h2 "Logo Design"


      2. The h3 elements, i.e.  "Logo Design", "Branding" , "Clearance" are  just a headers and will not be  links, right?

      /k
        • 19613
        • 70 Posts
        1. What’s the relationship between your documents? e.g. are "Corporate", "Small Business", "Clubs & Societies" and "More..." children of "Logo Design" or not? - I mean the h2 "Logo Design"

        Yes - I was thinking they should be ’children’ of the main visible menu link as in Logo Design.

        2. The h3 elements, i.e. "Logo Design", "Branding" , "Clearance" are just a headers and will not be links, right?

        Thats what I am hoping to achieve... the non menu item in my example under the Heading Clearance!:
        40% off all design books this weekend only. would just be text with a possible non-menu based link to Don’t miss out!

        I would pretty much like to be able to have is as exact to my sample as possible... I thought about individual wayfinder menus being called inside a page called by the main manu but I don’t think wayfinder works that way. huh

        thanks for the response
          • 16183
          • 1,390 Posts
          OK...lemme have a think....

          /k
            • 9130
            • 171 Posts
            The way to do this is to use the &categoryFoldersTpl parameter:
            [!Wayfinder? &categoryFoldersTpl=`NoLinkFolders`!]


            Create a chunk named NoLinkFolders containing:
            <h2 [+wf.classes+]><a href="#">[+wf.title+]</a></h2><div>[+wf.wrapper+]</div>

            and set the template of the non-link document to blank or set rel="category" in the link attributes field.

            Now the non-link documents should be identified by Wayfinder category folders and no link will be created for them in the menu.
              • 19613
              • 70 Posts
              Hi Etal
              Thanks for replying. I have been out for a few hours and I’ll be off to bed soon (I’m in UK). I’ll give that a try at some time tommorow and let you know. grin
                • 16183
                • 1,390 Posts
                Let me also venture a reply....you can read it tomorrow wink....in MODx...there’s almost always another way of achieving stuff....

                EDITED:

                I think I needed sleep too, ha! Anyway, I’ll post my proposed solution tomorrow....Basically it does away with some markup I don’t think you need? the h3, the divs, etc....nothing radically different from what etal has proposed above.....

                gnite/k
                  • 19613
                  • 70 Posts
                  Morning K
                  I await your ’proposed’ solution with all the exitement I can muster at this time in the morning.
                  ;)
                    • 16183
                    • 1,390 Posts
                    Hi,

                    Not tested yet but here’s another approach...

                    1. Create a 3 level menu
                    first level - Home, Logo Design, Stuff for Inspiratin, About us, Contact
                    Second level - Logo, Branding, Clearance, Design Tutorials etc - respectively
                    3rd level - Corporate, Small Business, Business cards, etc - respectively

                    2. Get rid of the extra markup in the menu - the divs and h2 and h3 unless it is necessary to have them. If that’s the case, we can edit the WF tpl chunks. Stick to ul and li.

                    3. Alter the CSS to style the new menu

                    3. Create 5 chunks - outerTpl, rowTpl, innerTpl, innerRowTpl and categoryFoldersTpl

                    Here are the chunks

                    outerTpl
                    <ul id="menu"[+wf.classes+]>
                    	[+wf.wrapper+]
                    </ul>
                    


                    rowTpl <!-- Here the class is applied directly but you can also use wf.classes if you wish. The top level menu will use this tpl-->
                    <li class="mega"> 
                     <a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>
                    [+wf.introtext+] <!-- this will pick up text from your document's summary,
                     e.g. in your sample page, the lorem ipsum in "Contact" & "About us" pages
                    Enclose within p tags-->
                    [+wf.wrapper+] <!-- sub-menus will appear here-->
                    </li> 
                    


                    innerTpl <!-- You will need a different wrapper from the outerTpl for you sub-menus -->
                    <ul>[+wf.wrapper+]</ul>
                    


                    categoryFoldersTpl <!-- This will be used for the 2nd level menu items which will not be clickable. They’ll also be h2 tags-->
                    <li class="categories"><h2>[+wf.linktext+]</h2>
                    [+wf.introtext+][+wf.wrapper+]</li>
                    <!-- Here the introtext will be used for the stuff such as the "40% off all design books this weekend only. Don't miss out". 
                    In your sample page example, this would be in the document "Clearance".
                     So - <p>40% off all design books this weekend only. <a href="[~id~]">Don't miss out</a></p>
                     Replace id with the document id you are linking to -->
                    


                    innerRowTpl <!-- This will be used by the 3rd level menu items -->
                    <li><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>,[+wf.wrapper+]</li>
                    [+wf.introtext+]
                    <!-- here the introtext is for the "More...."
                     I suppose the more is pointing to a document with a listing of other documents in the category?. 
                    So, it is basically a link. Create that link in the summary field of the last document in the sub-menu, e.g. for Branding category,
                     this would have to be in the document "Marketing". 
                    So - <li class="more"><a href="[~id~]">More....</a></li>. 
                    To validate the text needs to be enclosed in li tags by virtue of where they are appearing within the code -->
                    


                    4. "More...." - I think this can be achieved in other ways too depending on your circumstances. It might be difficult trying to remember which document will be containing this text since it has to be in the last document for every 3rd level menu item. If your menu will be growing, then the "More.." has to be moved to the "new" last document. There could be ways to get round this though. If you menu will not be growing then that’s not a problem.

                    5. The "More stuff for Branding"/"More stuff for Designers" are the trickiest bit. I don’t have a straight answer though I think you can pull them off as either part of the introtext in the categoryFoldersTpl - if you choose this solution then you will need to know which category document to place them in.....or, you can create these as child documents of their respective categories, making sure they are last in the menu and style them differently using the "last" class that will automatically be applied to them. I think this second method is probably not the way to go. If I get any more ideas will let you know.

                    That’s it. Sorry for the long post. I hope it works. The rest is basically css styling to make it look the way you want.

                    cheers/k

                    1st EDIT: Code edited for syntax errors (e.g. modx link tags and wf.wrapper)

                    2nd EDIT: SEE BELOW FOR ALTERNATIVE METHOD - This one here might also work but am too lazy to edit the CSS!
                      • 19613
                      • 70 Posts
                      Hi
                      Dood - That’s a whole lotta work you have done there... I will create and test ASAP and let you know my results (hopefully I won’t need to bother you again on this one!)
                      I know helping each other etc is the very spirit of community/open source... but I really appreciate your effort/time (so far wink ).

                      Looks like I will have to give you a whole lot of credit in my tutorial pages/site when I’m finished grin

                      Thanks
                      MT