Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be nice if contextual filters had a simple option to negate the results returned. Put another way, to eliminate what would otherwise be included based on that filter, just like regular filters have the radio button choice of "is one of" versus "is not one of."
As a particular use case, I want to eliminate the nodes authored by the logged-in user in a particular view.
Comment | File | Size | Author |
---|---|---|---|
#17 | views_handler_argument_numeric.inc-do-not-test.patch | 3.12 KB | kq_sb |
Comments
Comment #1
dawehnerIsn't there already the exclude checkbox on arguments?
Comment #2
msypes CreditAttribution: msypes commentedNot from what I can see, but that's exactly what I'm asking for.
Comment #3
dawehnerBut sure there is a checkbox on all numeric arguments.
Comment #4
msypes CreditAttribution: msypes commentedThe fact that you keep using the term "arguments" makes me wonder if we're on the same page/version.
I'm talking about 7.x-3.x-dev, where the term "contextual filters" has replaced version 6's "arguments."
More info: I did some poking/playing around. I do see an exclude checkbox under "More" if the Nid is used as the contextual filter.
However, there is no checkbox for author user id.
Content: User posted or commented
Maybe this should be switched from a feature request to a minor bug?
Comment #5
merlinofchaos CreditAttribution: merlinofchaos commentedThey're still called arguments internally. The checkbox is not available on all contextual filters. Which one, specifically, are you looking at?
Comment #6
msypes CreditAttribution: msypes commentedSee my original post and comment #4.
Content: User posted or commented
Comment #7
bobojo CreditAttribution: bobojo commentedI would like the same feature to be available for date fields. I want to get a view of everything that is not included in a certain date range as defined by Contextual Filters. Is this possible?
Comment #8
ofktoubro CreditAttribution: ofktoubro commentedI need the "negate" option on "Content: Has taxonomy term ID".
Because I want to show a block of nodes NOT tagged with the same as the content you are looking at... (as well as a block with nodes that ARE related to the content you are looking at)
Comment #9
Thorsten focus4 CreditAttribution: Thorsten focus4 commentedThanks a lot for this hint. The exclude checkbox is not easy to find. It is located at the collapsed "more" menu at the bottom of the "Configure contextual filter" dialogue.
Comment #10
ultimike@ofktoubro - I second this request - the ability to negate the "Content: Has taxonomy term ID" contextual filter would be sweet.
Thanks,
-mike
Comment #11
ravi.kumar CreditAttribution: ravi.kumar commentedHI,
I need to display the nodes created in the current year and in the result set need to hide the current months nodes.
So i added created year filter to do so, but for excluding current month's post, I am not able to find the negate option (for the month contextual filter).
So there must be negate option for this so that instead of passing multiple arguments for each months, we can filter data using a simple negate condition for current month.
Thanks
-Ravi Kumar
Comment #12
attheshow CreditAttribution: attheshow commentedI was also looking for the ability to negate the "Content: Has taxonomy term ID" contextual filter.
Comment #13
carcinovich CreditAttribution: carcinovich commentedSame thing. Problem is that contextual filter doesn't have a negate option when user IDs are selected.
Anybody know a short-term PHP code snippet fix?
Comment #14
meeli CreditAttribution: meeli commentedNegate is not the same as exclude.
I have content and flags.
I want to show all content *not* flagged by a given user.
Exclude shows all content that *is* flagged by every user except the given user.
I want to *negate* the "all content that is flagged by a given user" which would be "all the content that is not flagged by a given user" - different to showing all content that is flagged, excluding the current user.
Do not confuse negate with exclude.
Comment #15
AdamGerthel CreditAttribution: AdamGerthel commentedI have the same problem. Looking for a way to negate (not exclude!) a contextual filter.
Comment #16
codebeispiele CreditAttribution: codebeispiele commentedI have the same problem.
Any Ideas?
Comment #17
kq_sb CreditAttribution: kq_sb commentedThis patch works for what I need (negating a context filter to remove tagged nodes), but it's horribly hacky.
If someone has the time and/or Views experience to make this a more mature patch for inclusion, be my guest :)