I’m warming to the Drupal content management framework (as we’re apparently meant to call it). For getting a site up and running in record time, you really can’t beat it. Well, OK, maybe you can beat it with Rails, but I wouldn’t necessarily wager a lot on that. (I haven’t done, and don’t know anyone who’s done, a side-by-side comparison using people of roughly equal proficiency in both frameworks, and I really don’t have a guess as to how it would come out.) But it has a massively steep learning curve, and even once you’re getting the hang of things, it can still be really frustrating making it do exactly what you want.

Case in point – I’m making a new site for the Indiana University Swahili STARTALK summer program, and I would like to have my internal menus be styled without those annoying list dots. Is that so much to ask?

Yes. Yes it is.

Now, in Rails (or comparable write-it-yourself framework) this would be a piece of cake. Assuming I was even implementing the navigation menu as a list (which I probably would’t be, actually) in the first place, I’d just go to the partial view file, slap a class on the ul wrapper that contained the spec list-style-type: none, and DONE.

Now, to give Drupal its due, it does give me a pre-fab menu type, which other systems don’t. No matter what system I’m in, I have to style these things myself to get them the way I want them to look, so what’s the big deal?

The big deal, of course, is figuring out what to override to restyle the menu. Since the culprit leaf class is baked right there into the individual li elements, there’s really no choice but to use a theme template override.

So, I made a template.php file, put it in sites/all/themes/mytheme/, and added the following code:

function mytheme_menu_link(array $variables) {$element = $variables['element']; if ($element['#below']) {
$sub_menu = drupal_render($element['#below']);
}
$output = l($element['#title'], $element['#href'],$element['#localized_options']);
foreach($element['#attributes']['class'] as$k => $v){ if($v == 'leaf'){
unset($element['#attributes']['class']); } } return '' .$output . \$sub_menu . "n";
}