Calling all Drupal developers!
Help us get this on the first page of Digg. DIGG NOW!
Help us get this on the first page of Digg. DIGG NOW!
token_token_values($type, $object = NULL)
contributions/token/token.module, line 60
Sample implementation of hook_token_values().
type A flag indicating the class of substitution tokens to use. If an object is passed in the second param, 'type' should contain the object's type. For example, 'node', 'comment', or 'user'. If your implemention of the hook inserts globally applicable tokens that do not depend on a particular object, it should only return values when $type is 'global'.
object Optionally, the object to use for building substitution values. A node, comment, user, etc.
A keyed array containing the substitution tokens and the substition values for the passed-in type and object.
<?php
function token_token_values($type, $object = NULL) {
global $user;
global $base_url;
$values = array();
switch ($type) {
case 'global':
$values['user-name'] = $user->uid ? $user->name : variable_get('anonymous', t('Anonymous'));
$values['user-id'] = $user->uid ? $user->uid : 0;
$values['user-mail'] = $user->uid ? $user->mail : '';
$values['site-url'] = $base_url;
$values['site-name'] = variable_get('site_name', t('Drupal'));
$values['site-slogan'] = variable_get('site_slogan', '');
$values['site-mail'] = variable_get('site_mail', '');
$values['site-date'] = format_date(time(), 'short', '', variable_get('date_default_timezone', 0));
break;
}
return $values;
}
?>