I have created a custom content type 'games' and added a date field with the CCK module.
The date field in CCK still needs some tweaking but this is already issued.
Then I created a view with the views-module.
In the "add argument" list these values are displayed (and some more)
Node: Posted Year
Node: Posted Month
Node: Posted Week
Node: Posted Month + Year
Node: Posted Full Date
Date: Game_Date (field_game_date) -> This is my custom field.
It would be nice to have to have some more functionality to this custom date field:
Date: Year Game_Date (field_game_date)
Date: Month Game_Date (field_game_date)
Date: Month + Year Game_Date (field_game_date)
Date: Full Date Game_Date (field_game_date)
This would make the views-module even more powerfull than it is now.
| Comment | File | Size | Author |
|---|---|---|---|
| #21 | cck-arguments.gif | 14.47 KB | tmp |
Comments
Comment #1
merlinofchaos commentedThis would be a CCK feature request, not Views.
I'm not familiar with where the date field stands right now, but last I saw the text storage format made this sort of feature somewhat difficult to do, and doing so would be quite slow.
Comment #2
karens commentedI'm working on adding the ability to display a cck date in a calendar and in views in the event views module (http://drupal.org/project/issues/67060) and I'm also working on revisions to the cck date module (http://drupal.org/node/50062). There are some limitations in the way that cck fields are used in views, but I'm going to see if I can add some better options than the cvs version of the date module has.
Comment #3
tmp commentedHey KarenS,
Your event-views look great but I 'll have to wait for a revision of the CCK date.module because I have a lot of custom fields.
Comment #4
karens commentedFYI, I just posted updates for both cck date.module and to Event Views, use the links above to view them.
Comment #5
tmp commentedHey KarenS,
I already had a quick look at the new date-module. This is a big step forward !! Thanks
I created a date-field (with your patch) and a view to display my custom content type, but the view didn't display any date values. All other field types did display well in my view.
Comment #6
karens commentedWhen you say it didn't display any date values, do you mean there were no date fields to add to the view? It could be the cache. Did you try emptying it? Probably best to just truncate the cache table since both cck and views are doing lots of caching and it could be hard to figure which caches to clear.
Comment #7
tmp commentedI can add the date-field to the view. But the output of the view didn't show any date values.
I'll try the truncate-table-thing on my laptop.
PS. This is the website I would like to replace with Drupal ( http://www.volley-zoersel.be/cms/ploegen.asp ) The page consists out of 3 parts (team details, players info, games)
PPS. Another important item on my current my site: games per week ( http://www.volley-zoersel.be/cms/wedstrijden.asp?do=search&week=5 )
PPPS. This is my (Dutch only) test Drupal website (not updated yet with your latest patches) (http://cordoba.sohosted.com/drupal )
Comment #8
karens commentedTake a look at the latest postings on http://drupal.org/node/50062. Are the fields that don't show up fields created with the earlier version of the date module? If so, I think you need to update the .install file and run update.php, as described there. Then see if everything works.
Comment #9
moshe weitzman commentedjust changing title as needed.
Comment #10
tmp commentedI don't agree totally with the title-change ... please read my initial feature request.
Comment #11
tmp commentedSee initial feature request.
Comment #12
tmp commentedChanged to date-project.
Comment #13
RayZ commentedI agree about the need for flexible access to the date fields from views. I guess I'm not even sure I fully understand what can and can't be done currently. Specifically, I'd like to be able to set up a view that I can pass a date value (or 'now') and have it list the fields with values before (or after) that date.
Is this currently possible? With an appropriately placed php snippet, maybe?
Comment #14
karens commentedSee latest cvs and comments in http://drupal.org/node/76709.
Comment #15
RayZ commentedSorry for my ignorance on how to use the arguments, but can I now set up argument that would tell the view to list all dates greater than the supplied argument? How?
Greater than one arg and less than another (i.e. a date range) would be even better?
Thanks again for your help.
Comment #16
karens commentedArguments are be default filters that look for equal values. Adding in the ability to make an argument work to find dates greater or less than the selected value or for a date range would take a bit of work, so I'm putting that off until later.
Comment #17
RayZ commentedOK, thanks. That's what I thought, but I just wanted to make sure I wasn't missing something that's already there.
Comment #18
tmp commentedThanks for the new features !!
Would it be possible to add custom_date_field(by week) in the argument-list? This would allow me to list games (in my case) by week number. eg ?q=calendar/2006/52
Comment #19
karens commentedI've just checked changes into the cvs version of the date module. For the moment, this will still work with the 4.7 version of drupal and content.module. This has a completely re-written, very flexible date range argument.
You can put many different things into the argument to get the proper filtering of the dates - a range of dates, a date plus a time period, have the starting date in the range default to now, a specific week in a year, etc.
The argument expects a value like 2006-01-01::2006-01-15, or 2006W24, or @1W
From and to dates in argument are ISO dates, but can be shortened and missing parts will be added. Omitted parts of ISO dates will be assumed to be the first possible (for the from date) or the last possible (for the to
date) value in that time period
The 'to' portion of the argument can be eliminated if it is the same as the 'from' portion. If the 'from' portion is eliminated, the current date and time is assumed for the 'from' date.
Shortcuts are available:
Use @1H, @1D, @1W, @1M, @1Y to get next hour/day/week/month/year from now.
Use date before @ sign to get next hour/day/week/month/year from that date.
Use format like 2006W24 to find ISO week number 24 in year 2006.
Examples:
Groupby selector values are used only if a summary view of the argument is requested, possible values are by year, by month, by week, by day, and by hour
If summaries are used, navigating to the view with no argument will display subtotals for the query, grouped by the selected range, with a link to the complete query for each range
Don't use this on a production site yet. I wanted to get it out so people can help debug it before I branch a stable version to the 4.7 version of the module.
Be sure to pick up all the files when you update, I moved the views functions into a separate file.
Comment #20
karens commentedCommited new flexible argument handler to both cvs and 4.7 branches.
Comment #21
tmp commentedHey KarenS,
I created a new content type and Views with the latest CCK, dates and Views with Drupal 4.7.3.
The content type has a date field. I added the custom date as an argument in my view summarized by week.
The output of the view is incorrect (see attachment).
According to my MS Outlook calendar the 9th of sept. 2006 is in week 37 not week 36 as in the URL in the attachment.
I'll do some more testing on this.
Comment #22
karens commentedI am using ISO weeks, which counts the first week as a week starting on a Monday that has more than 4 days in the current year. According to that, Sept 9 is in week 36 (see http://personal.ecu.edu/mccartyr/isowdcal.html and http://en.wikipedia.org/wiki/ISO_8601 and http://www.proesite.com/timex/wkcalc.htm). So I got out a paper calendar and counted it out and came out with week 36 for Sept 9. That would mean MS is wrong, which is maybe not possible, or at least that they have their own idea about weeks. :-)
If you think I've interpreted it wrong, please correct me!
Comment #23
karens commentedFYI, I'm using ISO weeks because that's the standard, and because it's what is used by php and sql date functions to find the week number for a date.
Actually, I do see where MS came up with 37 - it's the 37th week if you ignore the ISO rule about looking only at weeks that have at least 4 days in them.
Comment #24
tmp commentedI think you're right :-)
I checked the week numbers against my paper calendar and my cell phone.
My current website is in ASP and all the week numbers are calculated the MS way !!
Thanks for the new features !!!!!
Comment #25
karens commentedIn reading through the ISO 8601 documentation, I decided I needed to tweak this a bit to have it better comply with the standards for duration and time interval, so I just committed an updated version to cvs. I plan to make the same changes to the 4.7 version as soon as I'm sure it's working correctly. You can try it out, just clear your cache first and re-create your view (drop the previous argument and add the new one back in).
Almost the same as before, but it uses a 'P' before the period instead of '@' and allows you to combine periods (i.e. P1Y2W3D looks for dates within 1 year, 2 weeks and 3 days of the selected start date). You can now use '@' anywhere a date would go to substitute in the current date at runtime.
Comment #26
webchickSubscribing; I owe you a patch review, Karen. ;) Will try and get that done tomorrow, sorry!!
Comment #27
webchickJust to report back, I double-checked the changes in the newest HEAD and they do indeed seem to be working as expected:
/P1W tells me all nodes that have a date field within the next week.
/2006-09-15--2007-03-15 gives me all nodes that have a date within this 6 month period.
Excellent!
Comment #28
fronbow commentedWould it be possible to get this functionality as a filter?
Comment #29
karens commentedSee http://drupal.org/node/76709.
Comment #30
(not verified) commented