5

Is there a way that I can display all possible values for tokens available on my Drupal installation? For example, I'd like to see all of the possible values for the [termalias-raw] placeholder that I use with the Pathauto module.

4

To see all the value a token would get, you should call the function that replaces a token with its value, passing a different value for its $object parameter.
Using pseudo-code, this is the code you should run:

foreach (get_all_nodes() as $node) {
  print token_replace("[termalias-raw]", 'node', $node);
}

"[termalias-raw]" is a token implemented by the Pathauto module that is associated with node objects.
This is the code contained in pathauto_token_list(), which is the function that lists all the token implemented by a module:

if ($type == 'node' || $type == 'all') {
  $tokens['node']['termpath'] = t('As [term], but including its supercategories separated by /.');
  $tokens['node']['termpath-raw'] = t('As [term-raw], but including its supercategories separated by /.');
  $tokens['node']['termalias'] = t('The URL alias of the taxonomy term.');
  $tokens['node']['termalias-raw'] = t('The URL alias of the taxonomy term.');
}

If you meant the list of all the tokens available, then that list is already given by the Pathauto module in the form that allows you to set the path alias for each entity supported by the module. To see it all you need to check each of the path alias types (e.g. user, node, taxonomy terms).

screenshot

  • +1, and the solution in Drupal 7: drupal.stackexchange.com/questions/15717/…. It works on my site. – Sk8erPeter Mar 8 '12 at 10:59
  • 1
    If Pathauto is installed, you can view a listing of all available tokens at admin/config/search/path/patterns under Replacement Patterns, in Drupal 7. – techmsi May 21 '13 at 14:05
4

In Drupal 7, the list is available at /admin/help/token Cheers.

  • No it's not - it shows tokens, bot not "all possible values for tokens". Of course if you know a way to get that list there, please share. Maybe I'm missing something, I just hardly needed this. – Mołot Aug 4 '14 at 11:15
2

This is very vague. Token values depend on providing data - so you'd be requesting to see what the token value is for every single node on your site?

I guess if you wanted to do this (assuming Drupal 6 and using the latest release of Token module):

$result = db_query("SELECT nid FROM {node} ORDER BY nid");
while ($nid = db_result($result)) {
  $node = node_load($nid, NULL, TRUE);
  echo "Node: $nid\t";
  echo "[termalias-raw]: " . token_replace('[termalias-raw]', 'node', $node, '[', ']', array(), TRUE);
  echo "\n";
}

Also, if you have the Devel module enabled, you should have a 'Devel' tab on all your nodes with a 'Tokens' sub-tab so that you can inspect all the tokens for a specific node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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