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.

CommentFileSizeAuthor
#21 cck-arguments.gif14.47 KBtmp
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

merlinofchaos’s picture

Project: Views (for Drupal 7) » Content Construction Kit (CCK)
Version: 6.x-2.x-dev » 6.x-1.x-dev
Component: Code » date.module

This 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.

KarenS’s picture

I'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.

tmp’s picture

Hey 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.

KarenS’s picture

FYI, I just posted updates for both cck date.module and to Event Views, use the links above to view them.

tmp’s picture

Hey 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.

KarenS’s picture

When 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.

tmp’s picture

I 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 )

KarenS’s picture

Take 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.

moshe weitzman’s picture

Title: CCK and Views » date module values not displaying

just changing title as needed.

tmp’s picture

I don't agree totally with the title-change ... please read my initial feature request.

tmp’s picture

Title: date module values not displaying » date module & arguments

See initial feature request.

tmp’s picture

Title: date module & arguments » date module & view arguments
Project: Content Construction Kit (CCK) » Date
Version: 6.x-1.x-dev » 7.x-1.x-dev
Component: date.module » Code

Changed to date-project.

RayZ’s picture

I 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?

KarenS’s picture

See latest cvs and comments in http://drupal.org/node/76709.

RayZ’s picture

Sorry 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.

KarenS’s picture

Arguments 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.

RayZ’s picture

OK, thanks. That's what I thought, but I just wanted to make sure I wasn't missing something that's already there.

tmp’s picture

Thanks 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

KarenS’s picture

I'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:

 *
 * --------- ARGUMENT --------  >> -------- RESULTING QUERY RANGE --------
 * 2006W24                      >> 24th ISO week in 2006
 * 2006                         >> the whole year of 2006
 * 2006-03                      >> the whole month of Mar 2006
 * 2006-02::2007-03             >> Feb 1 2006 to Mar 31 2006
 * 2006-08-31T14::2006-08-31T16 >> the 14th to 16th hours of Aug 8 2006
 * ::2006-12-31                 >> NOW to 2006-12-31T23:59:59
 * @3H                          >> NOW to three hours from now
 * @90D                         >> NOW to 90 days from now
 * @1Y                          >> NOW to one year from now
 * 2006-03-05@1W                >> the week starting Mar 5 2006
 * 2006-01@3M                   >> 3 months starting Jan 2006

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.

KarenS’s picture

Status: Active » Fixed

Commited new flexible argument handler to both cvs and 4.7 branches.

tmp’s picture

FileSize
14.47 KB

Hey 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.

KarenS’s picture

I 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!

KarenS’s picture

FYI, 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.

tmp’s picture

I 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 !!!!!

KarenS’s picture

In 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.

webchick’s picture

Subscribing; I owe you a patch review, Karen. ;) Will try and get that done tomorrow, sorry!!

webchick’s picture

Just 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!

fronbow’s picture

Would it be possible to get this functionality as a filter?

KarenS’s picture

Anonymous’s picture

Status: Fixed » Closed (fixed)