Needs review
Project:
EntityFieldQuery Views Backend
Version:
7.x-1.0-alpha1
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
5 Jun 2012 at 12:12 UTC
Updated:
24 Jun 2013 at 19:36 UTC
Jump to comment: Most recent file
Comments
Comment #1
chx commentedDo you use the Date module?
Comment #2
firebird commentedYes.
Comment #3
chx commentedThat's gonna be a challenge. I can not promise anything any time soon. I will try to slot this in some time in June. (I will check with my boss and if it's a priority for 10gen then obviously it will get done ASAP but he didn't indicate anything like that) My priority right now is entityreference.
Comment #4
firebird commentedWell, I decided to give it a go myself. Here's the patch. Very brief testing suggests that it works, but seeing as I have no experience in coding for Views, let alone EFQ Views, someone should go through the patch.
Comment #5
chx commentedJust like that and it works? Wowsie. Nice job. I havent yet applied but don't you need a field handler for proper output options?
Comment #6
firebird commentedUmm... I don't know. I just checked how it was done with the other content types and copied off that.
The patch includes a file called "efq_views_handler_filter_field_date.inc" . Is that a field handler?
What output options do you mean? How does a filter have output options?
I did check the options in the Views UI's "Fields" section, the date field's modal settings window, and they look like the ones in a regular View's date filter.
You know what to test and look for, so please apply the patch on a test installation and have look, when you have the time.
Comment #7
firebird commentedI think I messed up the patch regarding the newly added files. This might work better.
Comment #8
chx commentedI do not mean the filter, I mean display settings: field (which I think is the default) and then add field. I will check myself this the weekend if you don't get to it.
Comment #9
chx commentedOh sorry: the issue is about filter handlers and I was talking field handlers. Will take another look today.
Comment #10
japerryDoesn't apply cleanly to the latest version of efq_views
patching file efq_views.info
Hunk #1 succeeded at 33 (offset -6 lines).
Hunk #2 FAILED at 42.
1 out of 2 hunks FAILED -- saving rejects to file efq_views.info.rej
patching file efq_views.views.inc
Hunk #1 FAILED at 222.
1 out of 1 hunk FAILED -- saving rejects to file efq_views.views.inc.rej
patching file handlers/efq_views_handler_filter_date.inc
patching file handlers/efq_views_handler_filter_field_date.inc
Comment #11
japerryAn AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /admin/structure/views/view/event_listing/preview/page/ajax
StatusText: OK
ResponseText:
( ! ) Fatal error: Call to undefined function efq_views_op_prepare() in modules/efq_views/handlers/efq_views_handler_filter_field_date.inc on line 5
Call Stack
#TimeMemoryFunctionLocation
10.0001725736{main}( )../index.php:0
20.487164865064menu_execute_active_handler( )../index.php:21
30.499867032096call_user_func_array
( )../menu.inc:516
40.499867032520views_ui_build_preview( )../menu.inc:516
50.510467569848views_ui_preview( )../admin.inc:954
60.554370447760view->preview( )../admin.inc:176
70.557470598800views_plugin_display->preview( )../view.inc:1360
80.557470598848view->render( )../views_plugin_display.inc:2673
90.557470598896view->execute( )../view.inc:1184
100.557470598896view->build( )../view.inc:1116
110.576872112904view->_build( )../view.inc:987
120.577072114616efq_views_handler_filter_date->query( )../view.inc:1098
130.577172121752efq_views_handler_filter_field_date->op_simple( )../efq_views_handler_filter_date.inc:60
Comment #12
chx commentedDate module support has been added although it isn't using anything from this patch. Tests would be welcome.
Comment #13
chx commentedComment #14
japerryI've re-rolled a patch that adds granularity and other date functions to the date filter.
Comment #15
majorrobot commentedI've also run into the need for granularity, etc. in the date filter. I applied the patch from #14 and discovered that the patch only helps in the case of datestamp fields (aka Date (Unix Timestamp)).
I'm new at working with Views handlers, but it looks like the issue is in the op_simple() method where strtotime() is called on $value. This, of course, converts the value — with which we're performing the EFQ — into a Unix timestamp. If your field is a type of date field that is not datestamp, the query will likely return nothing.
To get around this, I'd recommend a few changes to the patch.
In op_simple(), add a switch statement to treat $value differently, depending on field type:
This, of course, only helps in the case of datetime fields — the iso_date type should be added, as well. I did play with that one for a bit, but did not make any progress.
I also noticed that the init() method doesn't discriminate between type of date field either. Therefore, I'd recommend moving the creation of the date_handler after the call for field info:
I'm not certain whether this changes much, but seems to be a step in the right direction if the code is depending on a date_handler.