[split from http://drupal.org/node/233062]

Hi,

obviously the "Station Programm: Now playing" views filter is not working...

Background: I want to set up a view (as a block) that displays the current program, as the built-in "Current Program/On Air" box does. Unfortunately, the "Now playing" filter never returns any results, no matter if a programm presently is playing or not.

Would be great if you could fix this.

tia,
Markus

Comments

hurricane_rufo’s picture

Just want to bring this up again. Could you please look into this? My site is to go live in three days, and this is kind of crucial...

I believe that the error might be somewhere in this function (schedule/views.inc, line 430):

function station_handler_filter_now_playing($op, $filterdata, $filterinfo, &$query) {
  switch ($op) {
  case 'handler':
    $query->ensure_table('node');
    $query->add_field('nid', 'node');
    $minute = '***CURRENT_STATION_MINUTE***';
    $query->add_where('EXISTS (SELECT * FROM {station_schedule_item} WHERE {station_schedule_item}.program_nid = node.nid AND {station_schedule_item}.start <= %d AND {station_schedule_item}.finish > %d)', $minute, $minute);
    break;
  }
}

as this results in the database query

SELECT node.nid FROM node node WHERE (EXISTS (SELECT * FROM station_schedule_item WHERE station_schedule_item.program_nid = node.nid AND station_schedule_item.start <= 0 AND station_schedule_item.finish > 0)) LIMIT 0, 2

I don't know enough PHP (and less about the Views API) at the moment to dig deeper; but maybe that bit helps to locate the error and fix it. I would really appreciate any hint.

tia,
Markus

drewish’s picture

Status: Active » Fixed

grab the latest version of HEAD, i'd updated some other views stuff that might have affected it because when i tried creating a view on my machine the now playing filter was working correctly. for reference here's what i was using:

  $view = new stdClass();
  $view->name = 'station_schedule_now_playing';
  $view->description = 'List of schedules with their currently playing program.';
  $view->access = array (
);
  $view->view_args_php = '';
  $view->page = TRUE;
  $view->page_title = 'Now Playing';
  $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 = 'table';
  $view->url = 'station/schedule/nowplaying';
  $view->use_pager = TRUE;
  $view->nodes_per_page = '10';
  $view->block = TRUE;
  $view->block_title = 'On Air';
  $view->block_header = '';
  $view->block_header_format = '1';
  $view->block_footer = '';
  $view->block_footer_format = '1';
  $view->block_empty = '';
  $view->block_empty_format = '1';
  $view->block_type = 'list';
  $view->nodes_per_block = '5';
  $view->block_more = TRUE;
  $view->block_use_page_header = FALSE;
  $view->block_use_page_footer = FALSE;
  $view->block_use_page_empty = FALSE;
  $view->sort = array (
  );
  $view->argument = array (
  );
  $view->field = array (
    array (
      'tablename' => 'node',
      'field' => 'title',
      'label' => 'Schedule',
      'handler' => 'views_handler_field_nodelink',
      'options' => 'link',
    ),
    array (
      'tablename' => 'station_schedule_item_current',
      'field' => 'program_nid',
      'label' => 'Current program',
    ),
    array (
      'tablename' => 'station_schedule',
      'field' => 'streams',
      'label' => 'Listen',
    ),
  );
  $view->filter = array (
    array (
      'tablename' => 'node',
      'field' => 'type',
      'operator' => 'OR',
      'options' => '',
      'value' => array (
  0 => 'station_schedule',
),
    ),
  );
  $view->exposed_filter = array (
  );
  $view->requires = array(node, station_schedule_item_current, station_schedule);
  $views[$view->name] = $view;
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

resin’s picture

Component: Programs » Schedule
Status: Closed (fixed) » Needs work

This problem still exists in 2.1-beta1 (and views.inc rev 1.19). I was able to fix get the desired functionality by stealing some code from the "Now Playing" block in station_schedule.module and adding it into views.inc.

Specifically, change this:

    $minute = '***CURRENT_STATION_MINUTE***';

to this:

    $ts = station_local_ts(time());
    $minute = station_minute_from_day_hour(date('w', $ts), date('G', $ts));

Step 3: Profit!

Update: It looks like the substitution of '***CURRENT_STATION_MINUTE***' isn't taking place because $minute ends up as zero. Maybe this is a Views bug?

drewish’s picture

Yeah I'd done some work on HEAD that addressed part of this: http://drupal.org/cvs?commit=265332
There's a patch that's in progress on #580806: Next Scheduled Program Block but it's more Views2 centric. station_minute_from_local_ts() could probably be easily back ported for 5.x-2.x.

jethroweb’s picture

Version: 5.x-2.x-dev » 6.x-2.0-beta4
tim.plunkett’s picture

Version: 6.x-2.0-beta4 » 5.x-2.x-dev
Status: Needs work » Postponed (maintainer needs more info)

This isn't relevant for 6.x, see comment #5. Putting back to 5.x, but postponing.

Is this still a valid bug report, or a feature request?

damienmckenna’s picture

Status: Postponed (maintainer needs more info) » Closed (won't fix)

The Drupal 5 versions are no longer supported, if someone would like to step up to co-maintain it then please do so, otherwise future work will only happen for D6 and D7. Thank you.