Drupal: Convert taxonomy term name to term id

11,510

you didn't show how do link to this views with agruments, if like this: http://site.com/views_page/taxonomy_name, then: arg(1) - it's you term_name, get id via: $term = taxonomy_get_term_by_name(arg(1));
result is $term->tid

But if http://site.com/views_page/taxonomy_name - is aliased path to taxonomy terms, views should see directly tids in argument handling via arg(2) in taxonomy/term/TID path.

Share:
11,510
imgrgry
Author by

imgrgry

Updated on June 04, 2022

Comments

  • imgrgry
    imgrgry almost 2 years

    Using 'taxonomy: term ID' as an argument in one of my Drupal views and I'm having trouble getting it to work correctly.

    On the views administration page it states, "if using term name, it is generally more efficient to convert it to a term ID and use Taxonomy: Term ID rather than Taxonomy: Term Name."

    How does one go about converting the term name from a URL into a term ID?