Pushing out your own tokens

If you are in need of custom tokens, here is an example of how to create custom token for a specific vocabulary.


/**
* Implementation of hook_token_values()
*/
function csm_support_token_values($type, $object = NULL, $options = array()) {
if ($type == 'node') {
$tokens['term-media-type'] = '';
$termArray = $object->taxonomy;
$tid_media_type = $termArray[15];
$term_obj = taxonomy_get_term($tid_media_type);
$tokens['term-media-type-tid'] = $term_obj->tid;
$tokens['term-media-type'] = strtolower($term_obj->name);
return $tokens;
}
}

/**
* Implementation of hook_token_list()
*/
function csm_support_token_list($type = 'all') {
if ($type == 'node' || $type = 'all') {
$tokens['taxonomy']['term-media-type'] = t('Media Type');
$tokens['taxonomy']['term-media-type-tid'] = t('Media Type tid');
return $tokens;
}

This might get patched in a new version of the token module: http://drupal.org/node/185446

Great..

Great article..
Good job ! Software Akuntansi