Hi,
I need to use html tags in menu (on the left side of site), like a <b>, <i>, <br> and others. Is it possible to disallow html filtering in menu items ? I tried to do it by this tutorial : http://www.computerminds.co.uk/allowing-html-drupal-menu-items , but it didn't work and all content of site disappeared.

Thanks.

Edited by: VeryMisunderstood; Added code tags around HTML

Comments

marcvangend’s picture

It looks like method that should work, but I think the code you linked to makes one huge mistake: the output of the theme is not returned. Let's try it one more time, like this:

First, make sure that a function called [yourthemename]_menu_item_link is not already declared in your theme's template.php file (replace [yourthemename] with the name of your theme).

Second, provided that [yourthemename]_menu_item_link does not exist, add this code to template.php (without the php tags):

<?php
function [yourthemename]_menu_item_link($item, $link_item) {
  return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL, NULL, FALSE, TRUE);
}
?>

The code above is exactly the same as the default theme_menu_item_link() (see http://api.drupal.org/api/function/theme_menu_item_link/5); I only allowed html content by setting the last argument for the l() function to TRUE.

zvonicek’s picture

Thak you very much marcvangend, it working !!! I use your code and replace [yourthemename] by my theme name (garland) and now, HTML tags are correctly showing in menu.

Thanks a lot for your help.
Zvonicek.

marcvangend’s picture

Thanks for your feedback, I'm glad I could help.

linwj’s picture

is there anyway to do this for drupal 6 ?

marcvangend’s picture

How about searching?
http://drupal.org/search/apachesolr_search/html%20menu, first result.

linwj’s picture

thanks for the help

unfortunately i searched up documentation first and i saw the code shown here was similar to the ones shown in the Theme snippets and got kinda hung up that , that was the way to work it.

closing my other thread and linking it here.

marcvangend’s picture

With Drupal, there are usually several ways to do something. The D5 method above can still be ported to D6, but the module option looks nicer, because you can choose to use html per menu item. If you want to use the method above in D6, override theme_menu_item_link (http://api.drupal.org/api/function/theme_menu_item_link/6) in your template.php and edit the line calling the l() function according to the documentation (http://api.drupal.org/api/function/l/6).