You are here

function theme_flag_tokens_browser in Flag 8.4

Same name and namespace in other branches
  1. 6.2 includes/flag.token.inc \theme_flag_tokens_browser()
  2. 7.3 flag.tokens.inc \theme_flag_tokens_browser()
  3. 7.2 flag.tokens.inc \theme_flag_tokens_browser()

Returns HTML for a tokens browser.

Parameters

array $variables: An associative array containing:

  • types: An array naming the types of tokens to show.
  • global_types: Whether to show global tokens.

File

./flag.tokens.inc, line 195
Flag module tokens support.

Code

function theme_flag_tokens_browser(array $variables) {
  $types = $variables['types'];
  $global_types = $variables['global_types'];
  if (\Drupal::moduleHandler()
    ->moduleExists('token')) {
    return theme('token_tree', [
      'token_types' => $types,
      'global_types' => $global_types,
    ]);
  }
  else {
    return '<p><em>' . t("Note: You don't have the <a href='@token-url'>Token</a> module installed, so the list of available tokens isn't shown here. You don't have to install <a href='@token-url'>Token</a> to be able to use tokens, but if you have it installed, and enabled, you'll be able to enjoy an interactive tokens browser.", [
      '@token-url' => 'http://drupal.org/project/token',
    ]) . '</em></p>';
  }
}