Drupal 7 – Use Checkboxes for Exposed Taxonomy Term filter in views

Drupa 7 Views renders exposed taxonomy term filters as either a select box / drop-down or an auto-complete. This may not be the best option especially if you allow the user to select multiple terms to filter with. So is there any way to render these filters as check-boxes instead? Well the bad news that you can’t by default, but the good news is that there is a module called Better Exposed Filters which allows you to do it easily!


To switch the filter to checkboxes, first install the module. Then make sure that your filters are exposed in block form – to do this open the ‘Advanced’ section in views and under ‘EXPOSED FORM’ set ‘Exposed form in block:’ to yes. Now change the ‘Exposed form style:’ setting to ‘Better Exposed Filters’ and then edit its settings by clicking on the ‘BEF Settings’ link.


drupal views exposed filter checkbox


In this screen find you taxonomy filter and in a select box like this ‘Display “tid” exposed filter as’ change the value to ‘Checkboxes/Radio Buttons’.


Now once you save your view the term filters should be rendered as check boxes!


drupal views taxonomy term exposed filter checkbox


Drupal 7 – Filter form not displaying in Views Block Display

If you have a view that exports a filter form, you may find that the form is not displayed when the view is rendered in a block as a ‘block display’, even though it may display perfectly in a ‘page display’ as part of the same view.


This problem had me rather worried until I came across this post, simply changing the ‘Use AJAX’ view setting to ‘Yes’ seems to solve the problem (at least it did for me! ;-))


To change this setting, click on the ‘Advanced’ area in the view’s settings, and in the section called ‘OTHER’ you will see a setting called ‘Use AJAX’, change this to ‘Yes’ and hopefully your filter form will now display as part of your block view!


Adare Bridal Website goes Live

Pride Design ( has put the new Adare Bridal ( website live.  Once again we have been working closely with pride on the development of this site.  The site is built using drupal 6 and uses custom CCK types and drupal views to model (pun intended) and display all those fantastic designers and their bridal gowns!


The site is a full CMS solution, the client can add, edit or remove content on the site including designers, dresses, special offers etc. by just logging in and using a simple content administration interface.

Passing an argument to a Block View in Drupal 6

Q: How can I pass an argument to a ‘block view’ in Drupal 6?

A: There is no way to pass an argument to a block view in Drupal 6, but don’t panic as there is a way to achieve the same result through some slight-of-hand.

The use of arguments with Drupal views are vital for getting the most out of the views functionality. How are the arguments normal passed to a view?  Well, if a view is configured to produce a page then the arguments are easily passed as part of the requesting URL,  while if a view is embedded using code, then the arguments are passed in as part of the call to embed the view.  But if a view is configured to produce a block, how do you pass arguments to it?  The bad news is you can’t – the good news is that there is a way fake it and achieve the same result.

The trick involves providing a PHP handler within the view which will be called when the view is invoked without an expected argument (this is what happens when the block is displayed!).  We just arrange for this handler to retrieve and return the argument’s value and then the view will behave as required – just as if the argument had been passed to it in the first place.

To do this create the block view as normal and configure the required argument(s).  For each argument we choose the ‘Provide default argument’ option, and select the ‘PHP code’ sub-option.  We then provide some PHP code which will ‘get’ and return the argument’s value, it doesn’t really matter where or how the PHP code gets the argument once it returns the correct value.   Have a look at screen shot below:

Adding a default parameter

The example above is a bit simplistic as the PHP code just returns a static value – not very useful at all!  A more realistic or useful example  (inspired by one of the posts referenced below) would be to return the argument that was passed to the page that contains and displays the block.  Consider the mythical paths:


Here things are set-up so that ‘web-design’ and ‘illustration’ are arguments to the ‘projects’ page, they result in only the projects of that type being displayed.   Assuming we are using the pathauto module for nice clean URLs (as we almost always are!) then the following PHP code when provided as the default argument handler will get the URL, parse it and return the argument part to the view.

[code lang="php"]
$path = drupal_get_path_alias($_GET["q"]); //get URL alias
$path = explode("/", $path); //break path into an array
if ($path[0] == "projects" && $path[1] != "")
  return $path[1];
} [/code]

So there is is, it’s definitely not the easiest method in the world but at least it does provide a mechanism of getting those arguments to the view…