Trying to figure out why my custom views filters didn't accept timestamps to filter against node.created.

This is the code

  $view = views_get_view('simplenews_digest');
  views_view_add_filter($view, 'node', 'created', '>', time(), '-100000');
  views_view_add_filter($view, 'node', 'created', '<', time(), '');
  //output the view
  views_sanitize_view($view);
 
  $newsletter['title'] = t('Title of newsletter');
  $newsletter['body'] = views_build_view('block', $view);
  $newsletter['teaser'] = node_teaser($newsletter['body']);

Found it had to do with the: views_handler_filter_timestamp

  if ($filter['value']) {
    $value = $filter['value'] == 'now' ? "***CURRENT_TIME***" : strtotime($filter['value']);
  }

Which just returns a FALSE if a timestamp is submitted.

The my HUGE patch contains 1 simple extra line ;-)

  if ($filter['value']) {
    $value = $filter['value'] == 'now' ? "***CURRENT_TIME***" : strtotime($filter['value']);
    $value = $value != FALSE ? $value : $filter['value'];
  }

Hope it can be committed in a next release. It would make Views work a little more logical (for me).

more here:
http://drupal.org/node/354965

Thanks for the nice module!

CommentFileSizeAuthor
views_module_filter_with_timestamp.patch626 bytessplash112

Comments

esmerel’s picture

Status: Needs review » Closed (won't fix)

At this time, only security fixes will be made to the 5.x version of Views.