Hi. I would like to be able to add a "view" with the ability to filter based on the "To:" date field.

I can currently use "Date: Name of field (field_whatever)" to filter the original date but not the "To:" date associated with it.

CommentFileSizeAuthor
#4 date_6.patch5.59 KBstefano73
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alex_b’s picture

Title: Sort view based on "To:" date » Sort and filter view based on "To:" date

+1 for this feature.

I think it would answer a pretty common use case.

I just tried to filter my events (CCK node type with date field) on my upcoming events view so that old events drop off the list and only new events show up. An event is an old event, when the to date is past.

I created the To: date with the To Date: option on the date field. When creating a view I can't select the To: date as a filter parameter.

PS: Thank you for your great module. Just started to use it.

minimism’s picture

+1 here...

I have an 'event' type which deals with events spanning multiple days... Of course, I want to display 'upcoming and current events' which will include events which are ongoing - therefore I need to filter on the 'to' portion of the date field (which is required in my content type).

I'm using Views to create the display blocks.

(As a specific example, there is an event running at the moment which started on Feb 13 and finishes on Feb 15. I need the event to display until Feb 15)

Drupal 5.1
Date 5.x-1.2
CCK 5.x-1.3
Views 5.x-1.5

alex_b’s picture

There is a patch by stefano73, I thought he had put it up already. Will drop him a line.

Alex

stefano73’s picture

FileSize
5.59 KB

Here's the patch. The following files have been patched:

- cck/content_views.inc
- date/date.module
- date/date_views.inc

yched’s picture

i did not actually check, but I think date.module already largely overrides default views definitions provided by content.module, so maybe there's a way the patch for content_views could be avoided ?

KarenS’s picture

This is an interesting idea -- adding a 'sorts' option as well as a 'filters' option to the field module. That might be good, but it's hard to know when to stop. Field modules might also need their own field or query handlers, etc etc. It might make more sense to just opt completely out of the default handling when there are a lot of changes needed.

I already posted a patch to content_views.inc to incorporate the callback handler which would allow the date module to opt out of the default CCK Views handling, so I'd like to get that patch applied. Then here, in the Date module, we'll use the callback to opt out and create the tables that are needed.

I've gotten along this far without the patch because the Date module's tables get created after the Content module creates them, so the Date module's version just overwrites the CCK version, but that is not a good enough system going forward since we can't be sure they'll always get created in the right order, hence the need for the callback patch.

Anyway, I'll take what is here and add it to other code I've already created and try to get this feature working in the next few days.

yched’s picture

that is not a good enough system going forward since we can't be sure they'll always get created in the right order
Agreed. I had not realized it relied on hook order fitting right. Not good indeed.
I'll try to review the content_views opt-out patch ASAP.

floretan’s picture

I'm guessing that if it is possible to have the option to sort by the "from" or the "to" field, it should also be possible to display these two fields separately. For example the timeline module requires two separate fields for the "start" and "end" values. I would also have a use for such separate but related fields on one of the projects I'm working on, but I don't know if the average user really needs it.

I realize that this adding even more fields to choose from, and that soon the drop-down list of the views configuration page is going to become unusable. So maybe it would be nice to have a settings page where it is possible to decide to hide some of these options.

KarenS’s picture

My plan is to have both from and to dates as fields, filters, and sorts. We need to finalize http://drupal.org/node/117621 since this is going to require some custom handling by the date module.

KarenS’s picture

I just committed a patch to add filters and arguments for the 'to' dates as well as the 'from' dates. A patch to add fields and sorts for the 'to' dates must wait until the content_views patch is finalized.

KarenS’s picture

Title: Sort and filter view based on "To:" date » Add fields and sorts for 'To' dates in Views

The content module patch has been applied, so this can move forward. Renaming to show what is still outstanding to work on.

srcerer’s picture

Can you confirm which version of the code has this functionality? I seem to have the additions to the views filter/arguments but I'm left wondering how to get the To and From dates in the Field. I am using CCK 5.x-1.5, Date 5.x-1.4 and Views 5.x-1.5.

Cheers!

KarenS’s picture

Status: Active » Fixed

I'm not making changes to the 5.1 version. I'm officially recommending you move to the 5.2 version now. If you have problems in that version you can check for existing issues or add new ones. Feature requests are now getting posted to the D6 version to be back-ported to 5.2.

This should be working in 5.2.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.