Handle menu entries with embedded HTML (resolves conflict with "Menu HTML" module)

Created on 6 May 2011, almost 14 years ago
Updated 29 March 2024, about 1 year ago

The Menu HTML module allows to add HTML to a menu item's name, which is usually used to display an icon next to the name, like this:

Menu link title <img src="/sites/mysite/files/myicon.png" />

When the "Append page title to breadcrumb" option is checked, the menu name will be determined by drupal_get_title(), which adds a check_plain() and thus destroys the angle brackets around HTML tags and a literal " character. Instead of the icon being displayed within the last piece of the breadcumb, the HTML source is displayed. To restore the image being displayed, menu_breadcrumb.module has to be changed as follows:

Change

  if (variable_get('menu_breadcrumb_append_node_title', 0) == 1) {
    if (variable_get('menu_breadcrumb_append_node_url', 0) == 1) {
      $breadcrumb[] = l(drupal_get_title(), $_GET['q'], array('html' => TRUE));
    }
    else {
      $breadcrumb[] = drupal_get_title();
    }
  }

(beginning on line 340) to

  if (variable_get('menu_breadcrumb_append_node_title', 0) == 1) {
    // drupal_get_title() adds check_plain() => angle brackets around HTML tags get lost => restore them
    $node_title = drupal_get_title();
    $node_title = preg_replace('/&lt;/', '<', $node_title);
    $node_title = preg_replace('/&gt;/', '>', $node_title);
    $node_title = preg_replace('/&quot;/', '"', $node_title);
    if (variable_get('menu_breadcrumb_append_node_url', 0) == 1) {
      $breadcrumb[] = l($node_title, $_GET['q'], array('html' => TRUE));
    }
    else {
      $breadcrumb[] = $node_title;
    }
  }

Would you consider to commit this change? Thanks.

โœจ Feature request
Status

Closed: outdated

Version

1.4

Component

Code

Created by

๐Ÿ‡ฆ๐Ÿ‡นAustria roball

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

    Closing a lot of ancient (> 4 years) issues. It's fine to re-open if you think there's something of value to be discussed.

Production build 0.71.5 2024