Adding title attribute with description to terms

Frank Ralf - March 6, 2009 - 21:22
Project:Tagadelic
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Frank Ralf
Status:closed
Description

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

#1

Frank Ralf - March 6, 2009 - 21:25

#2

Frank Ralf - March 7, 2009 - 12:34

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

tobiasb - March 7, 2009 - 17:24

#4

Frank Ralf - March 8, 2009 - 12:41

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

tobiasb - March 9, 2009 - 10:25

#6

Frank Ralf - March 9, 2009 - 12:18

Thanks!

#7

Bèr Kessels - March 10, 2009 - 07:11

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

tobiasb - March 25, 2009 - 15:17

Looks ok. see screenshot.

AttachmentSize
393494.jpg 24.44 KB

#9

Frank Ralf - April 15, 2009 - 16:42

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

Frank Ralf - April 15, 2009 - 16:46
Status:needs review» reviewed & tested by the community

changed status

#11

Frank Ralf - April 15, 2009 - 16:46

changed status

#12

Bèr Kessels - May 13, 2009 - 16:56
Version:6.x-1.2» 6.x-1.x-dev
Status:reviewed & tested by the community» fixed

Committed to 6 dev.

#13

Frank Ralf - May 14, 2009 - 06:57

Thanks!

#14

System Message - May 28, 2009 - 07:00
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.