menu-tree.tpl.php affects all menu
how I must set a template for one menu on ID or name?
please help!

Comments

chrisstina’s picture

I've got almost the same question. It sounds pretty stupid, but I couldn't find a way to do the following yet. I need to modify primary links output (add an extra div after each li). I tried overriding theme_menu_item() in template.php, but it affects all menus on the site (navigation, etc). How do I specify which menu to modify?

i-sibbot’s picture

You have to catch the primary links call and alter as you need.

//Catch only the Primary links
function phptemplate_links($links,$attributes = array('class' => 'links')) { 

	switch($attributes['class']){
		case 'primary-links': return themename_primary_links($links,$attributes);
			break;
	}	
  	
}

//The above calls this, when Primary links are fired, and catchs the call

function themename_primary_links($links, $attributes = array('class' => 'links')) {


  .... Your looping code for what you want to do goes here...


}

chrisstina’s picture

Thank you! This was really helpful.

drupalgeek’s picture

You can do drupal theming of menu by using the snippet on the link.