Главная » Web Development » Drupal » Override Drupal 7 taxonomy display by vocabulary

Override Drupal 7 taxonomy display by vocabulary


I've had a couple of cases recently where I've wanted to use views to override the output of taxonomy/term/%taxonomy_term on a site, but this can be tricky if you want to use different views for one or more specific vocabularies. Normally, you'd just enable the delivered Taxonomy Term view and modify it as needed for the site, and presumably that's how Drupal 8 will work by default with Views in Core. I've looked briefly at the Taxonomy Views Integrator module, but quite frankly, this task falls under customization for a specific site, so why not just customize for the site?

I looked around a little, and determined that the code I want to override is near the bottom of taxonomy_term_page(), starting where taxonomy_select_nodes() is called to build the contents. For this project, I really wanted to leave everything else alone (although I may come back and disable the RSS feeds, since I don't really need those, either.)

We start by overriding the page callback for taxonomy/term/%taxonomy_term to pass through a custom page callback function:

(view more)