views2

Custom Image Link in a Drupal View

The following code can be used in a views_customfield php field to create a custom image link. This example also shows how to use the db_query() function with a proper %-modifier.

Custom views image link

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.

Passing Arguments to Drupal Blocks