Index: station_playlist.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/station/playlist/station_playlist.module,v retrieving revision 1.13 diff -u -p -r1.13 station_playlist.module --- station_playlist.module 19 Oct 2007 15:55:35 -0000 1.13 +++ station_playlist.module 29 Oct 2007 18:36:05 -0000 @@ -495,35 +495,43 @@ function station_playlist_nodeapi(&$node case 'view': if (!$teaser) { // playlists - $time = time(); - $time_format = variable_get('station_playlist_program_dateformat', 'F j, Y'); + if ($view = views_get_view('station_playlist_upcoming')) { + // Set $view->url to current page so views with exposed filters submit + // back to the same page + $view->url = $_GET['q']; + $view_args = array($node->nid); - // pull all future playlists - $future_lists = array(); - $result = db_query('SELECT p.nid, p.timestamp FROM {station_playlist} p INNER JOIN {node} n ON p.program_nid = n.nid WHERE n.status = 1 AND p.program_nid = %d AND p.timestamp > %d ORDER BY timestamp', $node->nid, $time); - while ($playlist = db_fetch_object($result)) { - $future_lists[] = l(format_date($playlist->timestamp, 'custom', $time_format, 0), 'node/'. $playlist->nid); - } - if ($future_lists) { $node->content['playlists_future'] = array( '#type' => 'item', - '#value' => '', '#title' => 'Upcoming shows', + '#value' => views_build_view('embed', $view, $view_args, FALSE, NULL), '#weight' => 1, ); } - - // pull N recent playlists - $past_lists = array(); - $result = db_query_range('SELECT p.nid, p.timestamp FROM {station_playlist} p INNER JOIN {node} n ON p.program_nid = n.nid WHERE n.status = 1 AND p.program_nid = %d AND p.timestamp < %d ORDER BY timestamp DESC', $node->nid, $time, 0, 5); - while ($playlist = db_fetch_object($result)) { - $past_lists[] = l(format_date($playlist->timestamp, 'custom', $time_format, 0), 'node/'. $playlist->nid); - } - if ($past_lists) { + + if ($view = views_get_view('station_playlists')) { + // Set $view->url to current page so views with exposed filters submit + // back to the same page + $view->url = $_GET['q']; + $view_args = array($node->nid); + /* $view->page_type = 'list'; +var_dump($view->field); + $view->field = array( + array( + 'tablename' => 'node', + 'field' => 'title', + 'label' => '', + 'handler' => 'views_handler_field_nodelink', + 'options' => 'link', + 'fullname' => 'node.title', + 'id' => 'node.title', + 'queryname' => 'node_title', + ), + );*/ $node->content['playlists_past'] = array( '#type' => 'item', - '#value' => '', '#title' => 'Previous shows', + '#value' => views_build_view('block', $view, $view_args, FALSE, 5), '#weight' => 2, ); } Index: views_defaults.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/station/playlist/views_defaults.inc,v retrieving revision 1.8 diff -u -p -r1.8 views_defaults.inc --- views_defaults.inc 19 Oct 2007 17:10:02 -0000 1.8 +++ views_defaults.inc 29 Oct 2007 18:36:05 -0000 @@ -106,5 +106,66 @@ function station_playlist_views_default_ + + $view = new stdClass(); + $view->name = 'station_playlist_upcoming'; + $view->description = 'Upcoming playlists'; + $view->access = array ( +); + $view->view_args_php = ''; + $view->page = TRUE; + $view->page_title = 'Upcoming shows'; + $view->page_header = ''; + $view->page_header_format = '1'; + $view->page_footer = ''; + $view->page_footer_format = '1'; + $view->page_empty = ''; + $view->page_empty_format = '1'; + $view->page_type = 'list'; + $view->url = ''; + $view->use_pager = TRUE; + $view->nodes_per_page = '10'; + $view->sort = array ( + array ( + 'tablename' => 'station_playlist', + 'field' => 'timestamp', + 'sortorder' => 'DESC', + 'options' => '', + ), + ); + $view->argument = array ( + array ( + 'type' => 'program_nid', + 'argdefault' => '1', + 'title' => '', + 'options' => '', + 'wildcard' => '', + 'wildcard_substitution' => '', + ), + ); + $view->field = array ( + array ( + 'tablename' => 'station_playlist', + 'field' => 'timestamp', + 'label' => '', + 'handler' => 'station_handler_field_playlist_timestamp_program', + 'options' => 'listlink', + ), + ); + $view->filter = array ( + array ( + 'tablename' => 'station_playlist', + 'field' => 'timestamp', + 'operator' => '>', + 'options' => '', + 'value' => 'now', + ), + ); + $view->exposed_filter = array ( + ); + $view->requires = array(station_playlist); + $views[$view->name] = $view; + + return $views; }