Skip to content

Instantly share code, notes, and snippets.

@derhasi
Created October 7, 2011 12:44
Show Gist options
  • Save derhasi/1270202 to your computer and use it in GitHub Desktop.
Save derhasi/1270202 to your computer and use it in GitHub Desktop.
<?php
/**
* Implements hook_token_info()
*/
function mymodule_token_info() {
return array(
'tokens' => array(
'site' => array(
'mytoken' => array(
'name' => t("myToken"),
'description' => t("this is an example token."),
),
),
),
);
}
/**
* Implements hook_tokens()
*/
function mymodule_tokens($type, $tokens, array $data = array(), array $options = array()) {
$return = array();
if ($type == 'site' && isset($tokens['mytoken'])) {
$value = 'This is the token value i want to return';
$return[$tokens['mytoken']] = (!empty($options['sanitize']) ? check_plain($value) : $value;
}
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment