You are here

function pathauto_tokens in Pathauto 7

Same name and namespace in other branches
  1. 8 pathauto.tokens.inc \pathauto_tokens()

Implements hook_tokens().

File

./pathauto.tokens.inc, line 25
Token integration for the Pathauto module.

Code

function pathauto_tokens($type, $tokens, array $data = array(), array $options = array()) {
  $replacements = array();
  if ($type == 'array' && !empty($data['array'])) {
    $array = $data['array'];
    foreach ($tokens as $name => $original) {
      switch ($name) {
        case 'join-path':
          module_load_include('inc', 'pathauto');
          $values = array();
          foreach (element_children($array) as $key) {
            $value = is_array($array[$key]) ? render($array[$key]) : (string) $array[$key];
            $value = pathauto_cleanstring($value, $options);
            $values[] = $value;
          }
          $replacements[$original] = implode('/', $values);
          break;
      }
    }
  }
  return $replacements;
}