Move description out of the link

BarisW - October 5, 2009 - 13:11
Project:Vocabulary Index
Version:6.x-2.2
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:active
Description

Currently, the desciption is part of the link in the Alphabetical view. To fix this, open vocabindex_link.tpl.php and change:

$term->name .= $vi->node_count ? ' <span dir="' . $dir . '">(' . $term->node_count . ')</span>' : NULL;
// Tree views show term descriptions as link titles (tooltips), while other
// views show them directly under the term names.
if ($vi->view != VOCABINDEX_VIEW_TREE && $term->description) {
  $term->name .= '<span class="description">' . $term->description . '</span>';
  $title = NULL;
}
else {
  $title = $term->description;
}

echo l($term->name, $term->path, array('html' => TRUE, 'attributes' => array('title' => $title)));

into

$term->name .= $vi->node_count ? ' <span dir="' . $dir . '">(' . $term->node_count . ')</span>' : NULL;
// Tree views show term descriptions as link titles (tooltips), while other
// views show them directly under the term names.
if ($vi->view != VOCABINDEX_VIEW_TREE && $term->description) {
  $description = '<span class="description">' . $term->description . '</span>';
  echo l($term->name, $term->path) . $description;
}
else {
  $title = $term->description;
  echo l($term->name, $term->path, array('html' => TRUE, 'attributes' => array('title' => $title)));
}

#1

Xano - October 5, 2009 - 16:16

This is by design; I sacrificed semantics and accessibility a little to improve usability (larger clickable surface).

Why exactly do you consider this a bug?

#2

BarisW - October 6, 2009 - 07:36

You change the functionality of the default taxonomy setup. Titles should be clickable, not the description. If the only goal of your implementation is a better usability, you should use javascript (jQuery) to reach this goal. Semantics is a good thing, not only for disabled users, but also for search engines.

Check for example http://www.webdesignerwall.com/demo/jquery/block-clickable.html on how to get this working.

#3

regmanabq - November 26, 2009 - 19:55

Thanks Barris!!! i was just looking for a solution to that. Having a 40 word link is bad for SEO!

#4

BarisW - November 30, 2009 - 13:36

You're welcome!

The jQuery to get this working should be something like this:

$(document).ready(function() {
    $('ul.vocabindex li').css("cursor", "pointer").click(function(){
        window.location=$(this).find("a").attr("href");
        return false;
    });
});

 
 

Drupal is a registered trademark of Dries Buytaert.