-
Views Taxonomy: Get Terms with Associated Nodes
This example serves as both an example of how to alter a Views2 query, as well as how to use the get_terms_by_count() function I’ve written.
Unfortunately there is not (at present) a Views2 taxonomy filter that lets you “Get only terms with at least X associated nodes.” We had a client request that terms without associated nodes be hidden. This was actually more complex than it sounds, but the solution led me to a whole new level of Views2 understanding. Views2 has a hook called hook_views_query_alter() that lets you alter a Views2 query before it is executed. This is exactly what we needed to do in order to only pull terms with associated nodes. Specifically, we needed to add an additional WHERE clause to the query.
-
Passing Arguments to Drupal Blocks
You can pass any number of arguments to a Drupal block by providing default arguments. The screenshot below shows what an argument might look like in Views2.
-
Taxonomy Menus for Custom Views
Note: If you’re looking to just output a list of taxonomy terms that link to a custom view, please see PHP Code to Output a List of Terms Linked to a Custom View. If you need actual Drupal menu items for each term in a vocabulary to point to a custom view, please read on.