Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Copy Source | Copy HTML
- // Список токенов
- function hook_token_list($type = 'all') {
- $tokens = array();
- if (module_exists('taxonomy')) {
- if ($type == 'node' || $type == 'all') {
- $vocs = taxonomy_get_vocabularies();
- foreach ($vocs as $voc) {
- $tokens['node']['term-'.$voc->vid.'-path'] = t('As [term], but including its supercategories separated by /. In vocabulary ' . $voc->name);
- $tokens['node']['term-'.$voc->vid.'-path-raw'] = t('As [term-raw], but including its supercategories separated by /. In vocabulary ' . $voc->name);
- $tokens['node']['term-'.$voc->vid.'-alias'] = t('The URL alias of the taxonomy term. In vocabulary ' . $voc->name);
- $tokens['node']['term-'.$voc->vid.'-alias-raw'] = t('The URL alias of the taxonomy term. In vocabulary ' . $voc->name);
- }
- }
- }
- return $tokens;
- }
-
- // Tokens logic
- function hook_token_values($type, $object = NULL, $options = array(), $label = NULL) {
- $values = array();
- switch ($type) {
- case 'node':
- if (module_exists('taxonomy')) {
- $node = $object;
- $vocs = taxonomy_get_vocabularies();
- foreach ($vocs as $voc) {
- $vid = $voc->vid;
- $terms = taxonomy_node_get_terms_by_vocabulary($node, $vid);
- foreach ($terms as $term) {
- if (!taxonomy_get_children($term->tid)) {
- break;
- }
- }
- if ($term) {
- $values = array_merge($values, pathauto_token_values('taxonomy', $term, $options, 'term-'.$vid.'-'));
- }
- else {
- $values['term-'.$vid.'-path'] = $values['term-'.$vid.'-path-raw'] = $values['term-'.$vid.'-alias'] = '';
- }
- }
- }
- break;
- }
- return $values;
- }
Новый модуль Handy alias для гибкого создания синонимов страниц