1

I have a view which overrides the default taxonomy page. The view has a contextual filter which look for the tid in the URL.

My goal is to get the taxonomy term to display as the title of the page.

I tried setting the view's title to "Department: [field_dept]" (the field which references the taxonomy term and is loaded in the view). This work great, [field_dept] is replaced with the taxonomy term as expected.

There is an exception though. When the view has no results, there is no [field_dept] to look up and my page title looks like this "Department: [field_dept]" :-/

Now I'm trying to figure out how to get the taxonomy term from the tid, which is in the URL and available in my view.

Is there a function available in views that will return the term from a tid? Something like get_term_from_tid(%1), so I can use it in the title of the view or via title override in the contextual filter?

Drupal 7.14

Views 7.x-3.3

1

Do you use "Content: Has taxonomy term ID" field as contextual filter?

If yes then edit this filter, in "WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED" section check "Override title" and in appeared textfeild input "Department: %1"

"%1" will be replaced by the name of current term. If no term is specified "%1" will be replaced by "all".

If you want change word "all" then in section "WHEN THE FILTER VALUE IS NOT IN THE URL" click on "Exceptions", check "Override title" and specify your value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.