Closed (fixed)
Project:
Views Date Format SQL
Version:
7.x-3.0
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
27 Feb 2012 at 21:00 UTC
Updated:
23 Aug 2012 at 12:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
zany commentedA feature patch or sponsoring is welcome.
Comment #2
bago commentedHere is my attempt.
Loops through fields looking for is date and the views_handler_field_date handler and replace it with the new one.
Not sure if it is good to have such a loop in this method for performance (don't know how often this method is called).
Comment #3
zany commentedThat patch illustrates the concept. It does not work in any sensible way though (for me at least?).
Did you try Krumo (devel module) on the hook data? There is no key 'is date' anywhere.
Also your scope is to broad. You'll catch fields like Feeds import date, and file upload dates. Then the custom fields definitions are one level deeper afaik.
Thanks for sketching the idea though!
Comment #4
bago commented@zany it works fine here with that patch (i'm using it in 2 sites). I don't know if "is date" is created from some other module I installed. I didn't notice issues on other sides.
Comment #5
zany commentedOk. Let's keep it around as 'Needs Review' and get some comments on it.
The problem could be on my end. I do see the 'is date'-key in the Date module, but it doesn't show up in the hook data. Maybe an issue with module ordering.
Do you get the functionality on 'created' and 'changed' fields? Those are not from the Date module and don't have 'is date'. Does Date override something there for you?
Thanks.
Comment #6
webflo commentedYes date_views module add a "is date" to all date fields in date_views_views_data_alter().
Comment #7
bago commentedI see options:
1) leave the changed+created alterations and add my loop so to support the date module.
2) remove the "is date" check in my loop and simply rely on the name of the previous handler.
I see no harm in #2, so I think we could simply go with it and it should zany issues.
Comment #8
zany commentedThanks webflo, I didn't enable the date views module here:)
Bago, option 2 looks fine and works.
I'm still concerned about the scope. This walks across all modules and tables. do we really want all these?
(Feeds is the only non-core here as an example).
It might be nice to have it on all core fields, and it's opt-in after all... Thoughts?
Comment #9
bago commentedWe don't know what users will want to use in their views, so it sounds right to do this on all of them.
Either way we only enable the rewrite for fields where people flagged the checkbox.
I didn't test if it works against every field, but in my case I needed it to work in a custom field (and it works fine).
(in fact the sql rewrite behaviour should be used by default by views as the "current default option" produces unexpected results if you try to group by things).
Comment #10
zany commentedStrangely enough my Date-module fields are marked with views_handler_field_field not views_handler_field_date. Once I figure that out this patch gets released. Thanks again!
Comment #11
jurriaanroelofs commentedpatch #2 works fine for me, I can now SQL-format commerce entity fields. Probably it should also patch the .info file to list date_views as a dependency.
Comment #12
zany commented@JurriaanRoelofs can you try patch #8?
Also note that this module works without the Date module (for Created & Changed fields). So Date or Date_views are not a dependency.
Comment #13
jeremymcminn commentedJurriaan - does this work for Commerce order date fields? I've applied patch #2 however no checkbox shows up on my order date field settings.
Comment #14
jeremymcminn commentedManaged to get it showing, all working great for aggregation apart from the fact that it doesn't seem to sort by date. Adding a date sorting rule stops the aggregation from working.
See attached for without the date sorting, the months are in random places.
Comment #15
jeremymcminn commentedFor some reason adding MIn or Max to the aggregation settings for date field in sort criteria managed to get this in the right order.
Comment #16
jurriaanroelofs commentedI dont use min and max. I'll try to make time for this tomorrow.
Comment #17
jeremymcminn commentedCool - seems to be working fine for me at present with the Min & Max, no idea why though!
Comment #18
jurriaanroelofs commentedSorry for the slow reply. I just tested patch #8 and it works fine too.
Comment #19
zany commentedComment #20
bennos commentedhm. I did not get it on date field of a content type. date views module is enabled.
I tried one of the core fields and it works.
how can i figure out the problem? and how can I get it work?
Comment #21
zany commented@bennos did you use the new 3.1 version? If you know php you can use the devel module and dpm() to inspect the data structure in the hook. http://drupalcode.org/project/views_date_format_sql.git/blob/HEAD:/views...
Comment #22
mpisano commentedIt works on core fields ok, but I'm trying to apply to a date field in a field collection entity and doesn't work.
Any help?
Thanks
Comment #23
patsch_lux commentedI like to use this also for date fields created by myself, not just for the core dates like node.changed, node.created and so on.
Please can anybody help me?
I tried do make a new class:
I remove this code:
from the function views_date_format_sql_views_data_alter(&$data) .
Now i have the checkbox "Use SQL to format date" at my date fields, but it doesn't work.
Edit:
I got these errors:
Thx for helping me.
Comment #24
zany commentedPlease do not comment on closed issues. Open a support request ticket. Give more detail: what modules did you enable what exactly is the setup.