This code provides a token for taxonomy titles, very useful when used with the page title module. Can be added to the bottom of taxonomy_title.module

/**
 * Implementation of hook_token_values().
 */
function taxonomy_title_token_values($type, $object = NULL, $options = array()) {
  $values = array();
  switch ($type) {
    case 'taxonomy':
      $category = $object;
      
      // use taxonomy title if it exists, else category name
      if($token = check_plain(_taxonomy_title_get_title($category->tid))){
      }
      else {
        $token = check_plain($category->name);
      }
      
      $values['vocab-title'] = $token;

      break;
  }
  return $values;
}

/**
 * Implementation of hook_token_list().
 */
function taxonomy_title_token_list($type = 'all') {
  if ($type == 'taxonomy' || $type == 'all') {
    $tokens['taxonomy']['vocab-title'] = t("The vocabulary title from module taxonomy title if entered, if taxonomy title not specified will be taxonomy name (same as [vocab]).");

    return $tokens;
  }
}

Comments

hass’s picture

+1, code looks only like a prove of concept. After my review patch #636776: Full module review findings got in - I may work on this.

Amir Simantov’s picture

Could this code come in my template.php until module has this feature?

hass’s picture

Not sure if it works, but at least there are some naming bugs inside like ['vocab-title']. I believe it need to be named ['term-title'], but this is also a bug in the modules field name, too. The field on the term edit page is "improper" named Taxonomy Title and should better be Term title.

jenlampton’s picture

@Amir Simantov

This code will not work in your template.php, you would need a custom module to implement.

I am adding the token support into the next release, so hold tight :-)

Jen

jenlampton’s picture

Status: Active » Fixed

Committed to dev branch. new release coming shortly.

Jen

Status: Fixed » Closed (fixed)

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

A Romka’s picture

so this is not working is it?