Last active
August 29, 2015 14:08
-
-
Save jackfoust/650dc793352202dddb63 to your computer and use it in GitHub Desktop.
#drupal Custom Token. Drupal 7
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 | |
/** | |
* @file | |
* Creates a custom token. In this case this token was sent to Google Analytics. | |
*/ | |
function example_token_info() { | |
$info['tokens']['site']['active_alert'] = array( | |
'name' => t('Active Alert'), | |
'description' => t('Status of Alert.'), | |
); | |
return $info; | |
} | |
function example_tokens_alter(array &$replacements, array $context) { | |
$tmp = variable_get('alert_status', '0'); | |
$active_alert = !empty($tmp) ? 'TRUE' : 'FALSE'; | |
$replacements['[site:active_alert]'] = $active_alert; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment