Skip to content

Instantly share code, notes, and snippets.

@jackfoust
Last active August 29, 2015 14:08
Show Gist options
  • Save jackfoust/650dc793352202dddb63 to your computer and use it in GitHub Desktop.
Save jackfoust/650dc793352202dddb63 to your computer and use it in GitHub Desktop.
#drupal Custom Token. Drupal 7
<?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