views:

747

answers:

1

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?

+2  A: 

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.

Nikit
but how would I pass this value to my view argument?
gigantorTRON
Add argument on Views, see "Validator options", choose PHP code: read carefully comment there: You may change the argument by setting "$handler->argument". So you can change name to tid here.
Nikit

related questions