Custom Drupal Modules - creating filters for Views

| | Comments (0) | TrackBacks (0)

Continuing my exploration of custom modules and views, here is my code for allowing view builders to filter entries based on a status field, say "special offers" that is represented in our module's database table by an integer with 1 for true or 0 for false.

Add this key to your array entry for a table, at the same level as the 'join' key. See my earlier post for how the rest of the array works.

In this case, the database column is called "is_special_offer." The keys you should supply are discussed here in the Views handbook.

'filters' => array(
  'is_special_offer' => array(
     'name' => 'Product: Is Special Offer',
     'operator' => 'views_handler_operator_eqneq',
     'list' => 'views_handler_operator_yesno',
     'list-type' => 'select',
     'help' => t('Show only Special Offers'),
  )
)

0 TrackBacks

Listed below are links to blogs that reference this entry: Custom Drupal Modules - creating filters for Views.

TrackBack URL for this entry: http://bloggy.com/cgi-bin/mt4/mt-tb.cgi/3759

Leave a comment

About

A blog by Barry Hoggard, owner of Tristan Media LLC.

About this Entry

This page contains a single entry by published on July 3, 2008 3:40 PM.

Blueprint CSS framework was the previous entry in this blog.

Culture Pundits official launch is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.