Closed (fixed)
Project:
Taxonomy Title
Version:
6.x-1.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
12 Sep 2009 at 09:21 UTC
Updated:
30 Sep 2010 at 16:56 UTC
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
Comment #1
hass commented+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.
Comment #2
amir simantov commentedCould this code come in my template.php until module has this feature?
Comment #3
hass commentedNot 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.Comment #4
jenlampton@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
Comment #5
jenlamptonCommitted to dev branch. new release coming shortly.
Jen
Comment #7
A Romka commentedso this is not working is it?