This patch adds a title attribute to each term which will show the description of the term as a tool tip when hovering with the mouse over the term. (This is the default behavior with taxonomy terms when shown in nodes.)

The feature was requested in http://drupal.org/node/390870 and the solution described in http://www.drupalcenter.de/node/16915 (including screenshots).

Frank

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Frank Ralf’s picture

Frank Ralf’s picture

Slightly improved patch as recommend in http://www.drupalcenter.de/node/16915#comment-59445

  1. substituted function strip_tags($term->description) (originally from taxonomy.module, line 64) by check_plain() (http://api.drupal.org/api/function/check_plain)
  2. deleted quotes
  3. better indentation

Frank

tobiasb’s picture

Frank Ralf’s picture

Thanks for checking the code and improving it!

I had another look at the context of that title attribute code in taxonomy.module and tagadelic.module and found that neither strip_tags() nor check_plain() is actually needed in tagadelic.module because here the whole is wrapped in the link function l() which cares itself for removing all HTML and PHP tags from a tooltip:

  // Remove all HTML and PHP tags from a tooltip. For best performance, we act only
  // if a quick strpos() pre-check gave a suspicion (because strip_tags() is expensive).
  if (isset($options['attributes']['title']) && strpos($options['attributes']['title'], '<') !== FALSE) {
    $options['attributes']['title'] = strip_tags($options['attributes']['title']);
  }

So the change in tagadelic.module can be simplified to 'title' => $term->description,.

Frank

tobiasb’s picture

Frank Ralf’s picture

Thanks!

Bèr Kessels’s picture

I like it.

Can someone please give it a quick test on a site with real information?
After one or more positive tests, I will commit it to HEAD and Drupal 6.x.

tobiasb’s picture

FileSize
24.44 KB

Looks ok. see screenshot.

Frank Ralf’s picture

Does work as promised (see screenshot). I really would like to see it committed to HEAD.

tia
Frank

Frank Ralf’s picture

Status: Needs review » Reviewed & tested by the community

changed status

Frank Ralf’s picture

changed status

Bèr Kessels’s picture

Version: 6.x-1.2 » 6.x-1.x-dev
Status: Reviewed & tested by the community » Fixed

Committed to 6 dev.

Frank Ralf’s picture

Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.