diff --git includes/amazon.views.inc includes/amazon.views.inc index 8b427a0..ed81998 100644 --- includes/amazon.views.inc +++ includes/amazon.views.inc @@ -130,7 +130,7 @@ function amazon_views_data() { _amazon_make_simple_date_field($data, 'amazon_item', 'releasedate', 'Release date', 'The release date of the product.'); _amazon_make_simple_text_field($data, 'amazon_item', 'listpriceformattedprice', 'List price', 'The current list price of the item. (Unformatted)'); - _amazon_make_simple_text_field($data, 'amazon_item', 'invalid_asin', 'Invalid ASIN', 'If nonzero, the ASIN is invalid or discontinued by Amazon'); + _amazon_make_simple_boolean_field($data, 'amazon_item', 'invalid_asin', 'Invalid ASIN', 'If nonzero, the ASIN is invalid or discontinued by Amazon'); unset($data['amazon_item']['listpriceformattedprice']['argument']); // Define the base group of this table. Fields that don't @@ -195,6 +195,21 @@ function amazon_views_data() { return $data; } +function _amazon_make_simple_boolean_field(&$data, $table, $column, $title, $help = '') { + $data[$table][$column] = array( + 'title' => t($title), // The item it appears as on the UI, + 'help' => t($help), // The help that appears on the UI, + // Information for displaying a title as a field + 'field' => array( + 'field' => $column, // the real field + 'handler' => 'views_handler_field_boolean', + 'click sortable' => TRUE, + ), + 'argument' => array('handler' => 'views_handler_argument_numeric'), + 'filter' => array('handler' => 'views_handler_filter_boolean_operator'), + 'sort' => array('handler' => 'views_handler_sort'), + ); +} function _amazon_make_simple_text_field(&$data, $table, $column, $title, $help = '') { $data[$table][$column] = array(