Sarkari Naukri and Naukri

Wednesday, 3 April 2013

get path of taxonomy term id drupal




<?php// first, get a term object from a term ID

$term = taxonomy_get_term($tid);

// then, use the term object to get the unaliased path

$taxonomy_path = taxonomy_term_path($term);

// finally, lookup the path alias using drupal_lookup_path()

$taxonomy_path_alias = drupal_lookup_path('alias', $taxonomy_path);

?>
For Drupal 7 you can use: taxonomy_term_uri()
<?php

$term
= taxonomy_term_load($tid); // load term object

$term_uri = taxonomy_term_uri($term); // get array with path

$term_title = taxonomy_term_title($term);

$term_path = $term_uri['path'];

$link = l($term_title,$term_path);

?>
or simple soution
url('taxonomy/term/' . $tid);

1 comment: