Download & Extend

Provide token for taxonomy title - code

Project:Taxonomy Title
Version:6.x-1.1
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

#1

+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.

#2

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

#3

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.

#4

@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

#5

Status:active» fixed

Committed to dev branch. new release coming shortly.

Jen

#6

Status:fixed» closed (fixed)

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

#7

so this is not working is it?

nobody click here