I'm developing a drop down menu for my theme.
What i want to do is to take control of my primary links structure
basically i want a structure like this


<ul>
<li><a href="#" >First Level</a>


    <div>

    <dl>
     <dt><a href="# >Second level </a></dt>
     <dd><a href="#">Third level</a></dd>
     <dd><a href="#">Third level</a></dd>
     </dl>
     
    <dl>
     <dt><a href="# >Second level </a></dt>
     <dd><a href="#">Third level</a></dd>
     <dd><a href="#">Third level</a></dd>
     </dl>

    </div>
 </li>

and so on.....

</ul>
 

I managed to get primary links full-tree by adding this function to my template.php

function phptemplate_get_primary_links() {
  return menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
}

but I cannot figure out how to handle menu_tree output to match my structure.
Is it possible?

thanks in advance for your help :)

Comments

arh1’s picture

in Drupal 5, you'd provide your own implementation of the theme_menu_links function. in Drupal 6, i believe you'll just need to create a file called menu-tree.tpl.php... see the 5.x to 6.x theme upgrade handbook page to get started.

Lioz’s picture

i managed to achieve this in drupal5 but non in d6
the problem is that menu_links renders only the first level of the menu
what i need would be something like this to get different menu levels


function theme_links($links, $attributes = array('class' => 'links')) {
  $output = '';

// if (we are on the first level use normal list){


  if (count($links) > 0) {
    $output = '<ul'. drupal_attributes($attributes) .'>';

    $num_links = count($links);
    $i = 1;

    foreach ($links as $key => $link) {
      $class = $key;

      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class .= ' first';
      }
      if ($i == $num_links) {
        $class .= ' last';
      }
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page()))) {
        $class .= ' active';
      }
      $output .= '<li'. drupal_attributes(array('class' => $class)) .'>';

      if (isset($link['href'])) {
        // Pass in $link as $options, they share the same keys.
        $output .= l($link['title'], $link['href'], $link);
      }
      else if (!empty($link['title'])) {
        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (empty($link['html'])) {
          $link['title'] = check_plain($link['title']);
        }
        $span_attributes = '';
        if (isset($link['attributes'])) {
          $span_attributes = drupal_attributes($link['attributes']);
        }
        $output .= '<span'. $span_attributes .'>'. $link['title'] .'</span>';
      }

      $i++;
      $output .= "</li>\n";
    }

    $output .= '</ul>';
  }


// otherwise use this markup....ecc ecc..

  return $output;
}

don't know if it's possible thoungh