fbpx Allowing HTML in Drupal menu items | ComputerMinds Skip to main content

Allowing HTML in Drupal menu items

An article from ComputerMinds - Building with Drupal in the UK since 2005.
16th Dec 2007

Mike Dixon

Senior Mind

You have to be a little careful with this one, but there are many times when in would be very handy to have HTML in your Drupal menu items. For example, you might want your Drupal menu to have a <br> to force a break, or perhaps insert a <span> around some content to get a two-tone menu item

Add the following to your Drupal theme's template.php file

function phptemplate_menu_item_link($item, $link_item) {
    $output = l($item['title'], 

By setting the final paramater on the l function to true, we are telling Drupal that the menu item should be treated as HTML. NOTE this obviously means all your menu items will now not be filtered, so probably best not to use this on a site where punters can add menu items!