Is there a way to make the contextual filter (argument) filter by greater than and lower than, better yet if given an excluded NID take the date field from that node and use it for this comparison?

The use case is the following:

Say you have a list of bulletins (content type) and you want to create a block on the bottom of that bulletin page to show the 4 previous bulletins.

Files: 
CommentFileSizeAuthor
#18 1417886-18.patch3.23 KBultimateboy
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1417886-18.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#14 date-1417886-14.patch3.22 KBdealancer
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch date-1417886-14.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#2 1417886-date-operators-for-contextual-arguments.patch2.96 KBayalon
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in 1417886-date-operators-for-contextual-arguments.patch.
[ View ]
#2 date.operators.jpg85.55 KBayalon
#1 1417886-less-than-operators-for-contextual-arguments.patch5.58 KBrmontero
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1417886-less-than-operators-for-contextual-arguments.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

Title:Lower than operator for arguments'Less than' operator for contextual arguments
StatusFileSize
new5.58 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1417886-less-than-operators-for-contextual-arguments.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

I have attached a patch that would allow you to specify comparison operators other than 'equals' when using a date_field contextual filter (argument).

Status:Active» Needs review
StatusFileSize
new85.55 KB
new2.96 KB
FAILED: [[SimpleTest]]: [MySQL] Invalid patch format in 1417886-date-operators-for-contextual-arguments.patch.
[ View ]

This is an absolute genius feature.

It's now possible to pass an argument and display all nodes greater/lower than the passed argument (date).

I use this feature on a customer site.

Attached you find an updated patch for the latest date module.

@Karen: Could you have a look a this? It's really nice and I attached a screenshot for better understanding.

Status:Needs review» Reviewed & tested by the community

Wrong status, it's reviewed. The credits go to the thread starter.

Status:Reviewed & tested by the community» Needs work

The last submitted patch, 1417886-date-operators-for-contextual-arguments.patch, failed testing.

Applied the patch against -dev and flushed cache but the Operation option is not showing up on the form.

I'm trying to filter Content:Post Date, which requires adding Date:Date (Node) and then selecting the date field to use. So the contextual filter winds up looking like this: Date: Date (node) (Content: Post date)

I applied the patch and it worked properly for me, but I did it on version 7.x-2.5.

In order to see the operations select list, I had to use the 'Only this field' option under 'Dates to Compare', which makes sense to me

Status:Needs work» Needs review
StatusFileSize
new2.71 KB
PASSED: [[SimpleTest]]: [MySQL] 5,238 pass(es).
[ View ]

This will break all queries NOT using this new feature. The trick was to set the default value to NULL.

Need these operators for all numeric values. (ex: nid, tid, file size, uid...)

Thank you.

StatusFileSize
new2.66 KB
PASSED: [[SimpleTest]]: [MySQL] 5,238 pass(es).
[ View ]

This is a fantastic feature addition which I needed for a current project. I applied the patch in #7 and had a few issues with it - my updated patch solves the issues I was having.

Upon applying the patch, I did not see the operations select item. I tracked this down to the #access attribute of the new form item. Seems like the rest of the form items simply set #access to $access. This seems to be more consistent with the rest of the code and solved my issue of never being able to see the operations field.

Secondly, I began getting a few notices/warnings, and several views simply stopped functioning as desired:

Notice: Undefined property: date_sql_handler::$placeholders in date_views_argument_handler->query() (line 176 of [...]/modules/contrib/date/date_views/includes/date_views_argument_handler.inc).
Warning: array_merge() [function.array-merge]: Argument #2 is not an array in date_views_argument_handler->query() (line 176 of [...]/modules/contrib/date/date_views/includes/date_views_argument_handler.inc).

I solved this issue by removing the return; from the operations conditional. Returning seems to be unnecessary here. Removing this return; removed the notices/warnings and appears to make this patch act just as desired.

I have applied the above patch - date-1417886-9.patch - but cannot see the operators. I understand 'Operations' should appear below 'Dates to compare' - but it's not there for me. Am I doing something wrong?

The patch in #9 works for me.

However, it seems like this only works when you use "Date: Date (node)".

Adding the Date field directly does not give me the operators even when "Dates to Compare = Only this field".

StatusFileSize
new3.81 KB
PASSED: [[SimpleTest]]: [MySQL] 5,238 pass(es).
[ View ]

Hello,
I've been working on such idea on my side, and produced the patch attached. I don't know where we're at concerning this issue, but that'll be a way to up the topic.
This patch provides a field "operator" in arguments of type "Date: Date (Entity name)", which will be enabled only if "Dates to compare" = "Only this field".
Feel free to comment and tell me ways to improve my code, I feel like I forgot cases.

Thanks,
David

Status:Needs review» Needs work

Reviewed patch #9:

It works good. However we don't need to make operation field required, but need to add custom validation. There is a reason: if Dates To Compare field is set to Start/End Date Range, then this field is hidden, but still required and validation error is thrown.

StatusFileSize
new3.22 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch date-1417886-14.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Re rolled patch #9.

Status:Needs work» Needs review

Patch in #14 works exactly as expected (I applied to 7.x-2.6 Date), is fantastically useful, and saved my butt on a project. Let me know how I can test/help to get this patch get committed, because this opens up a lot of great use-cases for filtering content by date.

Thanks ultimateboy and dealancer!

Status:Needs review» Needs work

The last submitted patch, date-1417886-14.patch, failed testing.

Status:Needs work» Needs review
StatusFileSize
new3.23 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1417886-18.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Re-roll of #14.

18: 1417886-18.patch queued for re-testing.

Status:Needs review» Needs work

The last submitted patch, 18: 1417886-18.patch, failed testing.

Issue summary:View changes
Issue tags:+Needs reroll