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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Isn't there already the exclude checkbox on arguments?

msypes’s picture

Not from what I can see, but that's exactly what I'm asking for.

dawehner’s picture

But sure there is a checkbox on all numeric arguments.

msypes’s picture

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

merlinofchaos’s picture

They're still called arguments internally. The checkbox is not available on all contextual filters. Which one, specifically, are you looking at?

msypes’s picture

See my original post and comment #4.
Content: User posted or commented

bobojo’s picture

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

ofktoubro’s picture

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

Thorsten focus4’s picture

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

ultimike’s picture

@ofktoubro - I second this request - the ability to negate the "Content: Has taxonomy term ID" contextual filter would be sweet.

Thanks,
-mike

ravi.kumar’s picture

HI,

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

attheshow’s picture

I was also looking for the ability to negate the "Content: Has taxonomy term ID" contextual filter.

carcinovich’s picture

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

meeli’s picture

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

AdamGerthel’s picture

Issue summary: View changes

I have the same problem. Looking for a way to negate (not exclude!) a contextual filter.

codebeispiele’s picture

I have the same problem.
Any Ideas?

kq_sb’s picture

This 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 :)