G2 Glossary should assign a CSS class to glossary links

pathscollide - April 1, 2007 - 10:01
Project:G2 Glossary
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:fgm
Status:closed
Description

As far as I can tell, using the markup, G2 does not assign a CSS class to links to glossary entries. This makes it impossible to define styles for these links.

Defining a different style for glossary links (e.g. dashed underline and "help" cursor) can be useful because it lets users know where they are going.

#1

pathscollide - April 1, 2007 - 10:02

Sorry, the dfn tag in my previous post got filtered out. I meant to say "the dfn markup."

#2

pathscollide - April 1, 2007 - 11:19

This is how I modified g2.module.

<?php
function _g2_filter_process($entry)
  {
 
/* Create an associative array containing the desired class name and a title */
 
$definition_attributes['class'] = 'glossary-def-link';
 
$definition_attributes['title'] = 'Click to see definition';
 
$target = variable_get(G2VARREMOTEG2, G2DEFAULTREMOTEG2);
  if (
$target == G2DEFAULTREMOTENO) /* Then we are not using a remote glossary */
   
{
   
$target = G2PATHENTRIES;
    }
 
// $ret = l($entry, G2PATHENTRIES ."/$entry");
 
$path = urlencode(_g2_terminal_encode($entry));
 
/* Pass the associative array created above to the l() function */
 
$ret = l($entry, "$target/$path", $definition_attributes, NULL, NULL, TRUE, FALSE);
  return
$ret;
  }
?>

#3

fgm - April 1, 2007 - 13:01
Status:active» needs work

There's something interesting in your suggestion. However:

  • As per WCAG guidelines, section 13.1, $definition_attributes['title'] should be set to something
    contextually useful, not to something generic like Click to see definition. Possible
    examples include: the number of definitions matching the DFN and their respective contexts,
    or the beginning of the definition if only one definition matches the DFN
  • Since we are doing definitions within G2, the class name should probably be g2-dfn-link, instead of glossary-def-link, to avoid namespace collision with what glossary.module can use, and to mention this is dfn-related, not def-related
  • More importantly, the feature you outline would be best placed in a themeing function in the module, since it relates to output, instead of being located within filter processing. This would gain web devs the ability to completely theme these links instead of just addind a specific CSS format for them.

Could you prepare a patch addressing these points ? If successful, this could be a worthwile
addition to the module.

#4

pathscollide - April 2, 2007 - 17:58

Hi fgm,

Thanks for the tips. I will make the necessary changes in my code. However, sadly the patch and features you suggest are *way* beyond my abilities.

By the way, what do you mean by "the number of definitions matching the DFN"?

#5

fgm - April 2, 2007 - 18:05

A DFN can link to several definitions, because of homonyms. For instance, CSS can mean both "Content Scrambling System" or "Cascading Style Sheets", so the title of the A element generated from the DFN could mention the fact that there are 2 definitions for this initialism. Conversely, when only one definition exists, G2 could directly give the "expansion/definition" in the title of the A element.

Generating patches is not difficult: if you're on windows, use Tortoise CVS, just right click on the file you created and select Generate patch.

#6

fgm - June 16, 2007 - 09:45
Status:needs work» fixed

Today's version (1.15.2.13) now includes the class g2-dfn-link on "a" links generated from dfn elements by G2.

The part about links formatting, being theme-specific, has been ignored.

#7

Anonymous - June 30, 2007 - 09:45
Status:fixed» closed

#8

fgm - January 5, 2008 - 19:46
Version:4.7.x-1.x-dev» 5.x-1.x-dev
Status:closed» fixed

Added to today's D5 version: bumping issue version.

#9

Anonymous - January 19, 2008 - 19:53
Status:fixed» closed

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

#10

pathscollide - January 19, 2010 - 23:42
Version:5.x-1.x-dev» 6.x-1.x-dev
Status:closed» active

Hi there,

I'm finally getting around to upgrading and it looks like this didn't make it into the Drupal 6 version of the module. Would it be possible to add it?

Thanks so much!

#11

fgm - January 20, 2010 - 08:44
Assigned to:Anonymous» fgm

Confirmed on 6.x. I'll add it.

#12

fgm - January 20, 2010 - 21:13
Status:active» fixed

Fixed in today's HEAD, thanks.

#13

pathscollide - January 21, 2010 - 10:19

Thank you for the quick work on this!

#14

System Message - February 4, 2010 - 10:20
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.