Download & Extend

Adding title attribute with description to terms

Project:Tagadelic
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Frank Ralf
Status:closed (fixed)

Issue Summary

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

Comments

#1

#2

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

AttachmentSize
tagadelic_393494_title_attributes2.patch 1.76 KB

#3

#4

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:

<?php
 
// 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

#5

#6

Thanks!

#7

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.

#8

Looks ok. see screenshot.

AttachmentSize
393494.jpg 24.44 KB

#9

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

tia
Frank

AttachmentSize
393494_Tagadelic_title_tags.png 2.35 KB

#10

Status:needs review» reviewed & tested by the community

changed status

#11

changed status

#12

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

Committed to 6 dev.

#13

Thanks!

#14

Status:fixed» closed (fixed)

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