Drupal: convert taxonomy name to id terminology

Using "taxonomy: term identifier" as an argument in one of my Drupal views, and I'm having trouble working correctly.

On the views administration page, it says: β€œIf you use the name of a term, it’s usually more efficient to convert it to a term identifier and use taxonomy: term identifier, not taxonomy: term name.”

How can I convert a term name from a URL to a term identifier?

+4
source share
1 answer

you did not show how to refer to these views using agruments, if so: http://site.com/views_page/taxonomy_name , then: arg (1) is you term_name, get id via: $term = taxonomy_get_term_by_name(arg(1));
result $term->tid

But if http://site.com/views_page/taxonomy_name is an alias of the path to taxonomy terms, views should see tids directly when processing arguments via arg (2) in taxonomy / terms / TID.

+3
source

Source: https://habr.com/ru/post/1308420/


All Articles