theme_menu_links

Definition

theme_menu_links($links)
includes/menu.inc, line 916

Description

Returns the themed HTML for primary and secondary links. Note that this function is overridden by most core themes because those themes display links in "link | link" format, not from a list. Also note that by default links rendered with this function are displayed with the same CSS as is used for the local tasks. If a theme wishes to render links from a ul it is expected that the theme will provide suitable CSS.

Parameters

$links An array containing links to render.

Return value

A string containing the themed links.

Related topics

Namesort iconDescription
Menu systemDefine the navigation menus, and route page requests to code based on URLs.
Themeable functionsFunctions that display HTML, and which can be customized by themes.

Code

<?php
function theme_menu_links($links) {
  if (!count($links)) {
    return '';
  }
  $level_tmp = explode('-', key($links));
  $level = $level_tmp[0];
  $output = "<ul class=\"links-$level\">\n";
  foreach ($links as $index => $link) {
    $output .= '<li';
    if (stristr($index, 'active')) {
      $output .= ' class="active"';
    }
    $output .= ">". l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment']) ."</li>\n";
  }
  $output .= '</ul>';

  return $output;
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.