We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17412
    • 270 Posts
    Hi, looking for a Modx developer to code a mega menu for Wayfinder.

    Here are the details:

    Jacob Nielsen gives the mega dropdown a thumbs up in improving site navigation / information findability: http://www.useit.com/alertbox/mega-dropdown-menus.html

    Here’s jquery version: http://www.sohtanaka.com/web-design/examples/mega-dropdowns/ & http://www.sohtanaka.com/web-design/mega-drop-downs-w-css-jquery/



    Please PM me if interested and we’ll take it from there.

    Thanks.

      • 4310
      • 2,310 Posts
      Untested, but here is the code to put in a config file that should just about do it for the demo @ http://www.sohtanaka.com/web-design/examples/mega-dropdowns/#.
      Copy & paste into a file named mega_menu.config.php
      Upload it to assets/snippets/wayfinder/configs/
      Make your call like this [!Wayfinder? &config=`mega_menu`!]
      Add rel="category" in the Link Attributes field for each of the very top level parents
      Add the necessary CSS & JS files to your template
      <?php
      	$startId = 0;
      	$level = 3;
      	$selfClass = ''; 
      	$firstClass = '';
      	$hereClass = ''; 
      	$lastClass = '';
      	$parentClass ='';
      	
      	$outerTpl = '@CODE: <ul id="topnav">
              		[+wf.wrapper+]
      	</ul>';
      	/* This is the one used for the Products items on the demo */
      	$innerTpl = '@CODE:<div class="sub">
      	<ul>
      		[+wf.wrapper+]
      	</ul>
      	</div>';
      	// This is the one used for the Sale items on the demo 
      	/* $innerTpl = '@CODE:<div class="sub">
      		<div class="row">
      	<ul style="width: 225px;">
      		[+wf.wrapper+]
      	</ul>
      	</div>'; */
              $categoryFoldersTpl = '@CODE:<li><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a>[+wf.wrapper+]</li>';
      	$parentRowTpl = '@CODE:<li><h2><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a></h2></li>[+wf.wrapper+]';
      	$rowTpl = '@CODE:<li><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a></li>';
      	
      ?>

      If it works send me money grin
        • 17412
        • 270 Posts
        Great - thanks for that! I’ve tested and haven’t got it to work just yet though will cast some fresh eyes over it tomorrow. Will report back.
          • 4310
          • 2,310 Posts
          The code I posted was about half way there rolleyes
          Here’s a demo on a MODx testing site.
          Drop me a PM if you want to get in touch.
            • 17412
            • 270 Posts
            Thanks for your hard work Bunk.

            Full set of files for anyone interested in this: MegaMenu

            As an addition to this. I found this Jquery plugin very useful to control the height of the menu since.

            http://www.filamentgroup.com/lab/setting_equal_heights_with_jquery/
              • 5387
              • 15 Posts
              Awesome menu! Soh Tanaka is a great designer. I was wondering if anyone has taken his advice for code layout for SEO with ModX templates?
                Chris Kluis, MBA, MSE
                Director of Marketing
                Mintek Mobile Data Solutions
                EAM & CMMS Software
                EAM & CMMS Blog
                • 20413
                • 2,877 Posts
                You rock MODx!! cool
                  @hawproductions | http://mrhaw.com/

                  Infograph: MODX Advanced Install in 7 steps:
                  http://forums.modx.com/thread/96954/infograph-modx-advanced-install-in-7-steps

                  Recap: Portland, OR (PDX) MODX CMS Meetup, Oct 6, 2015. US Bancorp Tower
                  http://mrhaw.com/modx_portland_oregon_pdx_modx_cms_meetup_oct_2015_us_bancorp_tower
                  • 7408
                  • 1 Posts
                  Hye,

                  At first i’m totally new to MOdx so don’t be to hard on me smiley.

                  I was looking for this menu in modx version to use in my first project. I thougth i finally found the complete script ( 2 or 3 posts above ) But after downloading en usiing it i saw it was for the old version of modx. Can someone help me with a update for Modx revolution ?

                  thank you
                    • 5160
                    • 118 Posts
                    Did anyone put this together for MODx Revolution? I started trying to get Soh Tanaka’s mega menu code running in Revolution, got it part way done then came across this thread.

                    I can make it work setting chunks for each Wayfinder variable [outerTpl, innerTpl etc.] but not if I use a wayfinder config file in: /core/components/wayfinder/configs

                    Ta.
                      • 24150
                      • 4 Posts
                      Don’t know if this is an appropriate place to post this but I wanted to continue this topic... I have been trying to get this to work with revo and have not had much luck.
                      Credits to lokust and David Bunk for getting this to work in evo and the only thing I managed to get was 3 days of pulling hairs out!:P

                      If anyone can help steer me in the right direction i would GREATLY appreciate it smiley here goes:

                      1. I created 6 chunks and named them with the prefix mega-----
                      outerTpl=
                      <ul id="topnav">[[+wf.wrapper]]</ul>

                      innerTpl=
                      [[+wf.wrapper]]

                      categoryFoldersTpl=
                      <li><a href="[[wf.link]]" class="[[+wf.description]]" title="[[+wf.title]]">[[+wf.linktext]]</a> <div class="sub"> [[+wf.wrapper]]</div></li>

                      parentRowTpl=
                      <ul><li><h2><a href="[[+wf.link]]" title="[[+wf.title]]">[[+wf.linktext]]</a></h2></li>[[+wf.wrapper]]</ul>

                      innerRowTpl=
                      <ul><li><h2><a href="[[+wf.link]]" class="[[+wf.description]]" title="[[+wf.title]]">[[+wf.linktext]]</a></h2></li></ul>

                      rowTpl =
                      <li><a href="[[+wf.link]]" class="[[+wf.description]]" title="[[+wf.title]]">[[+wf.linktext]]</a></li>


                      2. i called javascript and css files
                      <link rel="stylesheet" type="text/css" media="screen" href="mega.css" />
                      <script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
                      <script type="text/javascript" src="jquery.hoverIntent.minified.js"></script>
                      
                      <script type="text/javascript">
                      $(document).ready(function() {
                          function megaHoverOver(){
                              $(this).find(".sub").stop().fadeTo('fast', 1).show();          
                              //Calculate width of all ul's
                              (function($) {
                                  jQuery.fn.calcSubWidth = function() {
                                      rowWidth = 0;
                                      noColumns = 4;
                                      //Calculate row
                                      $(this).find("ul").each(function() {   
                                          maxWidth = ($(this).width() * noColumns);           
                                          rowWidth += $(this).width();
                                                            if(rowWidth > maxWidth) {
                                                           rowWidth = maxWidth;
                                                           }
                                      });   
                                  };
                              })(jQuery);       
                              if ( $(this).find(".row").length > 0 ) { //If row exists...
                                  var biggestRow = 0;   
                                  //Calculate each row
                                  $(this).find(".row").each(function() {                              
                                      $(this).calcSubWidth();
                                      //Find biggest row
                                      if(rowWidth > biggestRow) {
                                          biggestRow = rowWidth;
                                      }
                                  });
                                  //Set width
                                  $(this).find(".sub").css({'width' :biggestRow});
                                  $(this).find(".row:last").css({'margin':'0'});         
                              } else { //If row does not exist...        
                                  $(this).calcSubWidth();
                                  //Set Width
                                  $(this).find(".sub").css({'width' : rowWidth});    
                              }
                          }
                        
                          function megaHoverOut(){
                            $(this).find(".sub").stop().fadeTo('fast', 0, function() {
                                $(this).hide();
                            });
                          }
                          var config = {   
                               sensitivity: 2, // number = sensitivity threshold (must be 1 or higher)   
                               interval: 100, // number = milliseconds for onMouseOver polling interval   
                               over: megaHoverOver, // function = onMouseOver callback (REQUIRED)   
                               timeout: 500, // number = milliseconds delay before onMouseOut   
                               out: megaHoverOut // function = onMouseOut callback (REQUIRED)   
                          };
                          $("ul#topnav li .sub").css({'opacity':'0'});
                          $("ul#topnav li").hoverIntent(config);
                      });
                      </script>
                      


                      * the css file is the unaltered mega.css from above http://www.howsoon.co.uk/products.html David Bunkers example. All parent category items have link attribute rel="category"

                      my call to start the mess is:
                      [[Wayfinder? &startId=`0` &level=`3` &outerTpl=`megaouterTpl` &innerTpl=`megainnerTpl` &categoryFoldersTpl=`megacategoryFoldersTpl`  $parentRowTpl=`megaparentRowTpl` &innerRowTpl=`megainnerRowTpl` $rowTpl=`megarowTpl`]]


                      from the example above in evo there is one step I didn’t complete and that was the wayfinder.inc.php line 163 edit:
                       } elseif ($resource['level'] == 2 && $this->_templates['innerRowTpl']) { // edited : orginal - } elseif ($resource['level'] == 1 && $this->_templates['innerRowTpl']) {


                      could that be my problem?

                      EDIT: forgot to mention the problem; the menu is showing in a single row and sub-categories in the tree are showing inline with the parent. There is no hiding of the child categories and definitely no rollover show.

                      Thanks to all you wayfinder gurus!