Closed (won't fix)
Project:
Views (for Drupal 7)
Version:
5.x-1.6
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
7 Jan 2009 at 09:58 UTC
Updated:
4 Aug 2010 at 18:12 UTC
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!
| Comment | File | Size | Author |
|---|---|---|---|
| views_module_filter_with_timestamp.patch | 626 bytes | splash112 |
Comments
Comment #1
esmerel commentedAt this time, only security fixes will be made to the 5.x version of Views.