Hello,

I'm searching for a solution for themeing a multilevel menu.
I have to style the <ul> class in the second level.

http://drupal.org/node/767404#comment-5413366

How to access in custom theme the second menu level? You can only overwrite all menu_tree's.
f.e.

/**
 * Implements theme_menu_tree().
 */
function bartik_menu_tree($variables) {
  return '<ul class="menu clearfix">' . $variables['tree'] . '</ul>';
}

How to access the link / menu depth?

Comments

id2it’s picture

Not the best way, but first try. Is it the drupal way?

function mytheme_menu_tree($variables){

	$attributes = array(
			'class' => array('navigation'),
	);
	$regExp = '/menu-mlid-(\d+)/i';
	if ( preg_match($regExp, $variables['tree'], $menu) ) {
		if ($menu[1]){
			$mlid = $menu[1];
			$depth = db_query("SELECT depth  FROM {menu_links} WHERE mlid = :mlid", array(':mlid' => $mlid))->fetchField();
			if ($depth > 0) {
				$attributes['class'][] = 'navigation-'.($depth-1); 
			}
		}
		
	}
	return '<ul ' . drupal_attributes($attributes).'>' . $variables['tree'] . '</ul>';
}