function view_alias_token_values in View Alias 6
Same name and namespace in other branches
- 5 view_alias.module \view_alias_token_values()
 
Implementation of hook_token_values()
File
- ./
view_alias.module, line 272  - view_alias.module
 
Code
function view_alias_token_values($type, $object = NULL, $options = array()) {
  include_once drupal_get_path("module", "pathauto") . "/pathauto.inc";
  $values = array();
  switch ($type) {
    case 'view_alias':
      $term = $object;
      $tid = $term->tid;
      $parents = taxonomy_get_parents_all($tid);
      $catpath = array();
      // borrowed from the way pathauto does it.
      foreach ($parents as $parent) {
        // Replace any / characters in individual terms which might create confusing URLs
        // check path_auto_ignore words for special characters
        $catpath[] = pathauto_cleanstring(check_plain(preg_replace('/\\//', '', $parent->name)));
      }
      // reverse the array to get the right order. this is to prevent trailing slashes '/'
      $values['catpath'] = strtolower(implode("/", array_reverse($catpath)));
      break;
  }
  return $values;
}