Expose custom table in Views 3

8 July 2011 - 10:36am -- binarycubes

Created a module call colours.module
/**
* Implementation of hook_views_api().
*/
function colours_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'colours') . '/views', // Placed all my views inside the views folder.
);
}

function colours_form_views_exposed_form_alter(&$form, &$form_state, $form_id) {
//probably possible to call the function alter form directly eliminating the need for the following if then statement
if ($form_id == 'views_exposed_form' && $form_state['view']->name == 'individual_awardees') { //Created a view called individual awardees
// Add our custom select list.
$form['sch_name']['#type'] = 'select';
$form['sch_name']['#size'] = 1;
$form['sch_name']['#options'] = colours_get_schools();

$form['game_code']['#type'] = 'select';
$form['game_code']['#size'] = 1;
$form['game_code']['#options'] = colours_get_games();
}
}

function colours_get_schools() {
//Get an return the array of schools.
return $schools;
}

function colours_get_games() {
//Get and return the array of games.
return $games;
}