Where is the Drupal 7 termpath?

Using the pathauto and token module in Drupal 6 allowed you to create URL aliases using the following pattern: [termpath-raw] / [title-raw].

However, this does not apply to Drupal 7. I understand that D7 is still in alpha, but the beta version looks pretty soon, and it is much better than D6 IMO.

Is this feature not yet available?

+1
drupal drupal-7
source share
5 answers

In Drupal 7, the word path means something very specific and, apparently, something different from the term pathpath, and it does not seem that any action has been taken to replace the tokens [*path] yet ( although this is a known question): BIKESHED: token for a term or menu item for the entire tree / hierarchy .

It seems that he is not going to turn it into a kernel and will remain part of the Token contributor, and even projects embedded in # D7CX will complete their Drupal 7 ports before the final version, which is quite possible near the end of the year.

+3
source share

Accompanying token module. There is more here because taxonomy tokens are not quite simple. Now they are fields, and we have not yet specified token support for D7 fields. This is what we need to do, though.

+1
source share

I’ve been racking my brains for several months about this issue, and finally found a solution that seems to work:

http://drupal.org/node/741914#comment-5025862

In short, I created a custom module that provides several additional tokens (which can be used in modules such as page name or pathauto). In code lag, tokens are replaced by the full hierarchical path of the taxonomy of either the node or the term of the taxonomy (for the marker, pointers are used for the URL and others for the page name).

The actual implementation can be found in the discussion on the linked page.

I hope this can help some people with their own implementations.

+1
source share

You can use the taxonomy_entity_index module with queue issue fixes. The only thing that is really bad is that you need to use the Drush command to create an index on a production site or somehow reimport the current content of the site.

0
source share

I don’t remember in which sandbox project I found this, but this is the perfect solution.

taxonomy_path_token.info

 name = Taxonomy Path Token description = Taxonomy path token creates a path of parent taxonomy terms of a node package = Token core = 7.x dependencies[] = token 

taxonomy_path_token.module

 <?php /** * Implements hook_tokens(). */ function taxonomy_path_token_tokens($type, $tokens, array $data = array(), array $options = array()) { $replacements = array(); if (!empty($tokens['taxonomy_path']) && !empty($data['node'])) { if(!empty($options['sanitize'])) { $sanitize = $options['sanitize']; } else { $sanitize = FALSE; } $node = $data['node']; $replacements[$tokens['taxonomy_path']] = $sanitize ? check_plain(taxonomy_path_token_get_parents($node)) : taxonomy_path_token_get_parents($node); } if ($type == 'array' && !empty($data['array'])) { $array = $data['array']; foreach ($tokens as $name => $original) { switch ($name) { case 'join-path-except-first': 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); $values[] = $value; } array_shift($values); $replacements[$original] = implode('/', $values); break; } } } return $replacements; } /** * Implements hook_token_info(). */ function taxonomy_path_token_token_info() { $info['tokens']['node']['taxonomy_path'] = array( 'name' => t('taxonomy_path'), 'description' => t('Custom taxonomy_path token.'), ); $info['tokens']['array']['join-path-except-first'] = array( 'name' => t('Joined path'), 'description' => t('The array values each cleaned by Pathauto and then joined with the slash into a string that resembles an URL.'), ); return $info; } function taxonomy_path_token_get_parents($node) { module_load_include('inc','pathauto','pathauto'); if(!empty($node->field_tags)){ $tid = current($node->field_tags); $tid = $tid[0]['tid']; } else{ return ''; } $parents = taxonomy_get_parents_all($tid); $paths = array(); foreach ($parents as $parent) { $paths[] = pathauto_cleanstring($parent->name); } $paths = array_reverse($paths); array_shift($paths); $pathauto = implode('/', $paths); return $pathauto; } 

Then add this "[node: taxonomy_path] / [node: title]" to your pathauto templates.

0
source share

All Articles