array( 'views_field_handler_flashvideo_nid' => array( 'parent' => 'views_handler_field', 'path' => drupal_get_path('module', 'flashvideo_views'), ) ) ); } function flashvideo_views_query_alter(&$view, &$query) { $field = $view->get_item( $view->current_display, 'field', 'nid' ); $files_table = 'files'; if ( isset( $field ) ) { $flashvideo_field = $field[ 'flashvideo_field' ]; if ( isset( $flashvideo_field ) ) { if ( $flashvideo_field == 'thumbnail' or $flashvideo_field == 'video' ) { $clause = "flashvideo.fid = ( select max( $files_table.fid ) from flashvideo fv_sub left join $files_table on fv_sub.fid = $files_table.fid where fv_sub.nid = node.nid and "; switch ( $flashvideo_field ) { case 'thumbnail': $clause .= "$files_table.filemime = 'jpg'"; break; case 'video': $clause .= flashvideo_get_flash_query( $files_table ); break; } $clause .= ' )'; $query->add_where( 0, $clause ); } } } } /** * Implementation of hook_views_data(). * * Exposes all fields to the views system. */ function flashvideo_views_views_data() { $data = array(); $data['flashvideo']['table']['group'] = t('FlashVideo'); $data['flashvideo']['table']['join'] = array( 'node' => array( 'left_field' => 'nid', 'field' => 'nid', ), 'files' => array( 'left_field' => 'fid', 'field' => 'fid', ), ); $data['flashvideo']['nid'] = array( 'title' => t('Video'), 'help' => t('Add a flashvideo thumbnail or video as a field to this view.'), 'field' => array( 'handler' => 'views_field_handler_flashvideo_nid', 'click sortable' => FALSE, ), ); return $data; }