0

I am creating a custom token using token_replace() and then adding hook_tokens_info() and hook_tokens in .tokens.inc file. Will this function work without token module ? I mean do we need token module for this function

2 Answers 2

2

You don't need the Token module to use the functions you mentioned in your question. They are defined in Drupal core.

References:

2

Since token_replace() is a Drupal 7 function, there is no need to install the Token module to get the tokens a third-party module, or one you developed, make available. The only reason to install the Token module is getting more tokens available, and some bug fixes for some of the tokens Drupal core implements.

// @todo Remove when http://drupal.org/node/1173706 is fixed.
$date_format_types = system_get_date_types();
foreach ($tokens as $name => $original) {
  if (isset($date_format_types[$name]) && _token_module('date', $name) == 'token') {
    $replacements[$original] = format_date($date, $name, '', NULL, $language_code);
  }
}
// Current date tokens.
// @todo Remove when http://drupal.org/node/943028 is fixed.
if ($type == 'current-date') {
  $replacements += token_generate('date', $tokens, array('date' => REQUEST_TIME), $options);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.