I am listing several term fields with options lists in views. I am using key|value pairs on the options list. Views outputs the key instead of the value. It should query the key then output the value.

I wrote a function ot handle this in pre-render hooks for now but it would be better to make the views handlers consistant with cck behavior.

my funciton:


/**
 * Extract term field printable value.
 *
 * $fid is the field id. Assume fid is secure.
 * $key is the machine readable name. On the left of the key|value pair
 */
function module_extract_printable_field($fid, $key) {
  $query = 'SELECT options FROM {term_fields} WHERE fid="%s"';
  $args[] = $fid;
  $result = db_query($query, $args);
  $options = unserialize(db_result($result));

  // Return the printable result or false if not found.
  return isset($options['options'][$key]) ? $options['options'][$key] : FALSE;
}

views can pull this options array as part of the query using "additional fields" also which is probably better but to solve this quickly you can just call this function in the view->render function.

Comments

b-prod’s picture

Version: 6.x-2.1 » 6.x-2.x-dev
Status: Active » Needs review
StatusFileSize
new2.19 KB

Hi!
If this patch fixes this bug, could you please mark this issue as "Reviewed by the community"?

b-prod’s picture

Status: Needs review » Fixed

Ported in the 6.x-2.2 version

Status: Fixed » Closed (fixed)

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