Created
October 7, 2011 12:44
-
-
Save derhasi/1270202 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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