In other words, can the argument provided to Views combine a hard date with a relative date?

Examples of arguments:
2014-03-21--now (where now = March 28, 2014)
today-7--2014-03-21 (where today = March 1st, 2014)

Comments

bisonbleu’s picture

Issue summary: View changes

Better examples

rdeboer’s picture

Hi bisonblue,

No it cannot do this at the moment.
It think it would be a useful extension.
Other examples:
yesterday--20 days
-4 weeks--3 months

I may have a crack at it at some point.
Also happy to receive patches.

Best,
Rik

bisonbleu’s picture

Hey Rick,

Thanks for the quick reply.

I was able achieve the required results after patching Views-7.x-3.x-dev with views-357082-153-7.x-3.x-dev.patch.

In short, this requires a contextual filter of type 'Global: Null'. The incoming argument e.g. 2014-03-21 is available and can be used in the improved Configure filter criterion UI. Pretty neat I say!

See issue https://drupal.org/node/357082 for more information.

Cheers

rdeboer’s picture

@bisonblue

That is some issue thread and some patch that https://drupal.org/files/views-357082-153-7.x-3.x-dev.patch.

What does it do?

Rik

bisonbleu’s picture

Simply said, it allows you to use an argument as a criterion in a standard filter.

Imagine you want to filter a view of events whose start date is 'greater than' [a-future-date] that you would set dynamically. You can now do it thanks to this patch.

  1. Add a contextual filter of type 'Global : Null'.
  2. Add a regular filter and check the option 'Use an argument provided by a contextual filter'.

The filter UI will change, allowing you to select your contextual filter as a criterion. Then just append the desired argument to the URL of the view and your good to go!

e.g. http://yourwebsite.com/path_to_your_view/[a-future-date]

rdeboer’s picture

Re #5: That's cool!

But then when you change the regular filter will it use that as the filter argument or will it the View remain "sticky" on the contextual filter appended to the View?
I guess that is where Views Filter Harmonizer comes in.
Rik

bisonbleu’s picture

If you change your filter and uncheck the option 'Use an argument provided by a contextual filter', nothing happens even if the argument remains in the URL. That's because the nature of a 'Global : Null' contextual filter is that it is ignored (i.e. not applied as a filter to the view).

I've heard about 'Views Filter Harmonizer'.
But I have yet to play with it.

rdeboer’s picture

Views Contextual Range Filter now supports date ranges like the following:

2014-03-21--now
--2014-3-29
now--
last year--next year
last month--tomorrow noon
six months ago -- 2 months ago

Works for node date properties (created, last updated dates) and for Date module fields (default and ISO formats and also Unix timestamps.

rdeboer’s picture

Assigned: Unassigned » rdeboer
Status: Active » Fixed

All Date module field flavours now support natural language date ranges:
o default Date
o Date ISO format
o Date Unix timestamp format

Also supported as before are node properties (date posted/created, date updated, both of which are timestamps).
Rik

Status: Fixed » Closed (fixed)

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