hi i need help with something.

i have a menu at the top with several li's, containing ul's that also contain lis.. pretty much like the one in this site [http://www.webmd.com].

i was wondering, how do i set a limit to the displayed li's in the ul of an li... i'm sorry it's a tad bit complicated because it's nested and all.. anyway, as you can see in that site, in the link Health A-Z, 3 columns(ul) that contains several

  • links each. the
  • links' displays are limited each column[ul]. for example if the limiter is "5" then it displays just 5 links JUST ON A SINGLE COLUMN if the links are less than or equal to 5. if it exceeds, it generates another column for displaying the excess links, so on and so forth.

    how do i do this?

    any help is greatly appreciated. thanks

  • Comments

    kanani’s picture

    Well this isn't specific to megamenu, but you could do something like this in your template.php

    /**
     * Create the footer mini sitemap from items in the menu.
     *
     * @param $hook
     *   The name of the template being rendered ("block" in this case.)
     */
    function theme_build_footer_sitemap(){
      // pull the tree data so we can cull the list if necessary
      $treedata = menu_tree_page_data('primary-links');
      
      //trim the children
      foreach($treedata as $key => $value){
        if($treedata[$key]['below']){
          foreach($treedata[$key]['below'] as $subkey => $subvalue){
            $treedata[$key]['below'][$subkey]['below'] = 0;
          } 
        }
      }
      // TODO
      // make any modifications to the treedata
      // limited each subnav to only 6 items.
      // if more than 6 items, ad a more link to point to the parent menu item
      
      // generate the html markup
      $output = theme('footer_sitemap_mini', $treedata);
      return $output;
    }
    

    The tpl file i'm calling above ( $output = theme('footer_sitemap_mini', $treedata);) looks like this

    <div id="footer-sitemap-mini">
      <div id="footer-sitemap-mini-primary">
        <?php
       
        foreach($menuTree as $key => $value){
          $link = $value['link'];
         // $links = menu_tree_output($menuItem);
          echo '<div class="footer-sitemap-mini-column"><h3>' . l($link['title'], $link['link_path'], $link['options']) . "</h3>";
         // $output .= '<div class="footer-sitemap-minimenu_tree_output($value['below']);
           if($value['below']){
            //echo theme('footer_sitemap_mini_columns', $value['below']);
            echo  '<ul>';
              foreach($value['below'] as $nestedvalue){
               $nestedlink = $nestedvalue['link'];
               echo '<li>' . l($nestedlink['link_title'], $nestedlink['link_path'], $nestedlink['options']) . '</li>';
               }
            echo '</ul>';
          }
         
         echo '</div>';
         
        }
        
        ?>
      </div>
    

    then reference it in your preprocess function

    function theme_preprocess_page(&$vars, $hook) {
      
      $vars['footer_sitemap_mini'] = theme_build_footer_sitemap();
     
    }
    

    then in your page.tpl.php (or other template file) you can do

    print $footer_sitemap_mini;
    
    Anonymous’s picture

    Category: feature » support
    ram4nd’s picture

    Title: Nested Ul li menu help !!! » Nested Ul li menu help
    Priority: Critical » Normal
    Issue summary: View changes
    Status: Needs work » Active