this small patch adds taxonomy term descriptions (if they exist) to term links via <a title="description"> so that you get some more information when you hover over term links. i think this is a useful addition and would like to see this hit core. thanks!

Comments

ax’s picture

StatusFileSize
new1.01 KB

argh! - IE "save as text" escapes >s ... please take this ok patch.

Steven’s picture

Committed.

dries’s picture

UnConeD, what would happen when the description uses HTML code?

Steven’s picture

Good point... I took a look at drupal_attributes() though, shouldn't it be running values through drupal_specialchars?

In the meantime I guess a strip_tags would do it. Though, should we strip newlines as well? A test here shows the IE can handle newlines in title attributes (and displays them properly in the tooltip), while Firefox doesn't (displays them as odd symbols).

With titles being used more and more we could use a generic title-sanitation function.

moshe weitzman’s picture

We currently use taxonomy descriptions as title attributes in glossary.module and taxonomy_dhtml.module. I agree with using strip_tags() but please don't strip linebreaks. They are very useful for long glossary definitions and such.

ax’s picture

i had thought about html in descriptions and even tested it. balanced html works and is displayed as-is in the hover popup. what doesn't work would be a description like

">ending the <a tag

as the descriptions (as part of the taxo admin) are normally done by trusted users who know what they are doing, as this may be useful for some descriptions, and to keep things simple, i think it is safe to use as it is now.

the "generic title-sanitation function" steven suggested might be helpful, though.

nedjo’s picture

Assigned: ax » nedjo
Category: feature » bug
StatusFileSize
new1.24 KB

There are two issues produced by the use of term descriptions in title attributes.

The first, suggested above, is caused by HTML in the title attribute.

Consider a category with the following description:

This category is about <a
href="http://www.drupal.org">drupal</a>.

When enclosed in a title attribute, this becomes

<a href="taxonomy/term/4" title="This category is about <a
href="http://www.drupal.org">drupal</a>.">drupal</a>

which is invalid XHTML because of the quotation marks and generates display errors. Here's an example link (hold mouse over to see popup):

drupal">drupal.

Therefore, we should indeed use strip_tags().

The second issue is that some taxonomy descriptions may be longer than is appropriate for use in a tooltip popup, leading to (a) large downloads and (b) display ugliness. This latter issue is reported in the post
http://drupal.org/node/9491. It will be a particular issue for users who use the taxonomy_context.module, which provides support for displaying extended descriptions (equivalent to the body of a node) and any other modules making similar use of the term descriptions.

The attached patch addresses both length and HTML issues in term descriptions used as title attributes. It passes term descriptions through node_teaser() and then strips out tags before returning them. The result is a shorter (where necessary), tag-free display, appropriate for the title use.

marqpdx’s picture

hi All,
I'm a user of the last feature. I have a moderately extensive description in my taxonomy items. i then assign the taxonomy url to a menu item, and when the user clicks on it, they go to what amounts to a "Landing Page" for all the items in the Taxonomy (thanks to the Taxonomy_Context module), the description serving as static text that comes before all nodes which are added.

If description is supposed to function well as a tool tip, it shouldn't be a text area, but a single line (text input), and there should be another data element for the taxonomy. Perhaps breaking the description into two pieces, the ShortDecs (tool tip) and the LongDesc for use with taxonomy_context and other modules.

I'm new enough i don't know how to implement this, but i wanted to add my two cents.

Thanks,
mark

marqpdx’s picture

dries’s picture

I removed the title attribute from these links. The proposed solution is a bit of hack, and so is the idea of a 'generic title sanitation function'. If we want this back, we need to introduce a textfield that can be used to provide a link description.

killes@www.drop.org’s picture

Category: bug » feature

I consider this a feature request.

ñull’s picture

Just adding an idea here. Why not use the

here too? The hover-over-titles could be before this tag.

ñull’s picture

Sorry, but the break tag was filtered out, and used, of cause. Well, I guess that you know now what I mean!

LAsan’s picture

Version: x.y.z » 7.x-dev

nedjo: still a feature request?

mdupont’s picture

Version: 7.x-dev » 8.x-dev
mgifford’s picture

Issue tags: +D8UX usability

This is a simple 2 line patch that's been open since 2004. It's probably too late for D8, but should be something the UX folks should be looking at if it's going to get in at all.

Otherwise, let's close it.

mgifford’s picture

Status: Active » Closed (won't fix)

So much has changed within core/modules/taxonomy/taxonomy.module

I'm going to just close this for now, but feel free to re-open it if it is something that will be useful for you.