Theming change to add an ability to get access to raw tids (and thus custom theming)

sethcohn - June 3, 2009 - 20:31
Project:Content Taxonomy
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

For D5, there was this patch, #347727: Theming: Allow theming of taxonomy links
For D6, there is this patch, #303486: Display Type - List

Can someone please add SOME form of themeable function? Right now, the only options are Text or Link, meaning that despite the view returning a tid (or series/array of tids), the formatting is forced to do a lookup for the term name, and then either uses that, or worse, runs it thru a l() to generate a fixed link to the term.

Just adding a simple theme hooking as a new choice of formatting, ala the above patches, would mean that if you need to do something else besides 'term' or 'link' you could. Right now, the theming workarounds end up being direct views hacking, or doing node_loads on the nid returned just to get the actual tid list (despite that the view already knows about it, but we have no clean way to get it via theming), or worse, looking up term names to (hopefully) get the tid back the other way...

#1

mh86 - September 5, 2009 - 12:37
Status:active» fixed

both formatters are theme functions:

/**
* Theme function for 'default' text field formatter.
*/
function theme_content_taxonomy_formatter_default($element) {
  if (!empty($element['#item']['value'])) {
    $term = taxonomy_get_term($element['#item']['value']);
    _content_taxonomy_localize_term($term);
    return check_plain($term->name);
  }
}


/**
* Theme function for 'link' text field formatter.
*/
function theme_content_taxonomy_formatter_link($element) {
  if (!empty($element['#item']['value'])) {
    $term = taxonomy_get_term($element['#item']['value']);
    _content_taxonomy_localize_term($term);
    return l($term->name, taxonomy_term_path($term), array('attributes' => array('rel' => 'tag', 'title' => $term->description)));
  }
}

#2

System Message - September 19, 2009 - 12:40
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.