Созонов Алексей

Веб-разработчик

Изменить путь термина таксономии

09.08.2015

function MY_MODULE_entity_info_alter(&$entity_info) {
  $entity_info['taxonomy_term']['uri callback'] = 'MY_MODULE_taxonomy_term_uri';
}

function MY_MODULE_taxonomy_term_uri($term) {
  switch ($term->vocabulary_machine_name) {

    case 'vocabulary_one':
      return array(
        'path' => 'vocabulary-one/' . $term->tid,
      );
    break;

    case 'vocabulary_two':
      return array(
        'path' => 'vocabulary-two/' . $term->tid,
      );
    break;

    default:
      return array(
        'path' => 'taxonomy/term/' . $term->tid,
      );
    break;
  }
}

#Drupal