Posts

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 – Undefined variable: output in drupal_var_export() in dvm()

If you get the following error when using devel’s dvm() in drupal 7 (or indeed, if you see it when not using dvm()):

 


Notice: Undefined variable: output in drupal_var_export()

Then try putting this line into you settings.php file:

 


ini_set('error_reporting', 'E_ALL ^ E_NOTICE');

 

It worked for us – thanks to citytree for the fix!

 

Drupal 7 – Programatically setting Link field value

The method for Programmatically setting a link field value (see the Link module) in drupal 7 is slightly different from how it was set it in drupal 6. Here is some code for creating a new node and setting its link field (called field_url):

 


$node = new stdClass();
$node->type = 'website';
node_object_prepare($node);

$node->title = $site_name;
$node->language = LANGUAGE_NONE;

$node->field_url[$node->language][0]['title'] = "ridgesolutions.ie";
$node->field_url[$node->language][0]['url'] = "ridgesolutions.ie";

node_submit($node);
node_save($node);