There are occasions when you want to exclude a single path from something that would normally be handled through a wildcard, e.g. you want one node/add page handled a specific way but all of the rest of them the same. It would be useful to have a way of doing this within the admin.

Comments

garywiz’s picture

We have this exact problem, and it's getting worse the more we use Context (but we love Context! reallly we do)

The ....OR....OR...OR... nature of context sometimes makes contexts SO inclusive that it is hard to create some specific contexts.

I think some kind of "processing order" or "weighting" may help. We have this problem not just with paths, but also with nodes:

* Include nodetype1 nodetype2, etc.
* EXCEPT on the home page, or another page, etc.

The idea of NEGATIVE conditions for contexts seems very very appealing to me across the board.

I am about to upgrade from beta4 to beta7, maybe some changes have taken place, but if not, the more contexts you start using, the more necessary it is to be able to have a "NOT" operator somewhere. My fear is it may complicate the interface.

What really is needed is something akin to "Rules" where you can add a condition and specify an order of conditions, along with "not" operators for each. So, having a context triggered by a list of conditions would make much more sense than the current "any of the following" interface.

frankcarey’s picture

This work might make it easier to have more fine grained control using rules. #591114: Rules integration

greggles’s picture

Component: User interface » Code

Subscribe (this is code and UI, but mostly code, IMO)

tanc’s picture

+1 for the concept of negative conditions or a 'NOT' operator (Ideally in version 6.x-3.0).

tanc’s picture

Version: 6.x-2.0-beta7 » 6.x-3.0-alpha2

yhahn or jmiccolis, any thoughts on NOT operators?

yhahn’s picture

I'll think about this but atm I don't think this will be implemented in any kind of generalized way. It may make more sense on a per-condition plugin basis, e.g. path (with an additional field for excluded paths).

steve_uk’s picture

Any further thoughts on this? I'm using Context to replace the block visibility options and would be grateful to see an option to exclude paths

vkr11’s picture

+1 to negate. Even a path exclude would be great !!

frankcarey’s picture

has anyone looked at #2? It's been working really well for us. You can just make a rule that fires when a context is set, and then unset or change the context based on other rules conditions.

yhahn’s picture

Version: 6.x-3.0-alpha2 » 6.x-3.0-beta4
Assigned: Unassigned » yhahn

Moving versions up. Will think more about this.

finex’s picture

subscribing

c4rl’s picture

Subscribe

chriscalip’s picture

subscribe
note-to-self: context/block assignments finally adding the option of excluding certain paths. good stuff.

chriscalip’s picture

Version: 6.x-3.0-beta4 » 6.x-3.0-beta5
Status: Active » Needs review
StatusFileSize
new1.3 KB

Needed this for a project of mine, and it looks like a few folks also need this functionality. The attached file contains the module negate_path, a context conditional plugin module. It gives users the option to add a condition "Show on every page except the listed pages." enjoy.

aufumy’s picture

StatusFileSize
new4.18 KB

thanks chriscalip, works for me.

Here it is as a patch file.

aleksey.tk’s picture

Thanks for the module, chriscalip, works fine for us, you have saved us a lot of time!

P.S. Also thanks for the nice piece of Drupal humour :D

// $Id: negate_path.module,v get_er_done help_i_dont_want_to_maintain_modules

donquixote’s picture

subscribe..
i would like to exclude admin

tim.plunkett’s picture

Title: Option to exclude certain paths » Option to negate conditions
Status: Needs review » Active

The context_extras module now has the "negate path" plugin, and I just submitted a "negate taxonomy" plugin over at #847312: Additions to the module because I needed it for a site build.

yhahn, I know you said you didn't think there would be a general negate option for each field, but I really think that it is worth reconsidering. I can easily see the use cases for it, and it would stop me from writing an inverse plugin for every plugin in context :)

tim.plunkett’s picture

#813954: Path exclusion and active context condition can be used as a very specific inverse context.
It only passes if no other contexts have passed.

q0rban’s picture

Subscribe

yhahn’s picture

Version: 6.x-3.0-beta5 » 6.x-3.x-dev
Priority: Normal » Critical
yhahn’s picture

Status: Active » Postponed

See http://drupal.org/node/813954#comment-3267016 for excluded paths and contexts.

I'm not sure about negation for every single condition before 3.x stable. Definitely something to consider down the road.

rokr’s picture

A generalized way would be great. At this moment i need a way to display a block for authenticated users who don't have a specific role. (It is an apply for that role link).

so +1, rokr :-)

mparker17’s picture

+1. This would be really really useful for me!

pixelsweatshop’s picture

subscribe

doublejosh’s picture

Listening. Would love this especially for roles. Want some menus for all users except a certain role.

yesct’s picture

i need it for a role too. I want to show a block for only users who dont have a certain role.

I'm using inline css to hide taxonomy term links for all users who are not admins.

dddbbb’s picture

+1

damienmckenna’s picture

FYI, in case you missed it (as I had) you can negate paths by adding a tilde in front of it, e.g. if you want to match everything except for "admin" you'd set the path value to ~admin

dddbbb’s picture

That's excellent news - how'd I miss that? Perhaps this needs to be made a little clearer?

pixelsweatshop’s picture

How about ~ ? Say for sitewde context?

joachim’s picture

Status: Postponed » Active

> FYI, in case you missed it (as I had) you can negate paths by adding a tilde in front of it, e.g. if you want to match everything except for "admin" you'd set the path value to ~admin

This really needs to be in the UI, and there's no reason to postpone that at least.

mparker17’s picture

Maybe this is the wrong issue, but I would be interested in having a "negate" checkbox for every condition, not just the paths.

nlambert’s picture

Glad I read this!

Actually, this already seems to be in the UI. I'm using rubik and when I hover over the path field I can see the following help text :

Set this context when any of the paths above match the page path. Put each path on a separate line. You can use the "*" character as a wildcard and ~ to exclude one or more paths. Use for the site front page.

However, the font makes the tilde look like a minus (-) ... or maybe its my eyes.

Cheers

djroshi’s picture

+1 for negating role condition

doublejosh’s picture

This is actually possible, though not optimal... You can add a context condition and negate it.

So create your content type context or whatever, then create a second context for a role (eg: user_trial)
Then have the first context have a context condition with ~user_trial.

This does lead to some needless context bloat, but it will get the job done.

djroshi’s picture

That's awesome :)

pixelsweatshop’s picture

Status: Active » Fixed
q0rban’s picture

Priority: Critical » Normal
Status: Fixed » Active

Please leave this feature request open until there's a generalized solution for negating conditions.

kevinquillen’s picture

How can I negate a context if you receive a 403 error?

yareckon’s picture

cfbauer’s picture

I don't think the language is very clear. Here's what it says:

You can use the "*" character as a wildcard and ~ to exclude one or more paths.

It says to use the ~ character to exclude paths, but it doesn't say how your'e supposed to do that. It would be better if the text read like this or similar:

Place the ~ character in front of a line to exclude it

dsim’s picture

Thanks cfbauer. It saves my time.

AlessMascherpa’s picture

You can do many things like this one with http://drupal.org/project/context_rules

Cheers
Alessandro Mascherpa

escoles’s picture

It's all well and good that you can negate paths, but what about other kinds of conditions?

E.g., I have a need to perform an action whenever the user agent indicates that the browser is NOT IE 6, 7 or 8. That's actually really, really hard to do if you can't just create a positive matching condition and negate it.

So I think this is kind of an important feature. Without it, working with Context often feels like trying to program a Register Machine.

joachim’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev
Assigned: yhahn » Unassigned
Issue summary: View changes

Rather than create a second version of every plugin, would it be possible for Context core to add a negate option itself at the bottom of each plugin's form, and that way every plugin is automatically negatable?

markdc’s picture

+1 for negate roles

jantoine’s picture

jantoine’s picture

anybody’s picture

I can confirm this issue is very very important... how can we proceed here?

giupenni’s picture

+1

delacosta456’s picture

hi
please is it possible to extend this patch(for numeric values to ) for more option like :

Not equal to
Less than
greater than
etcc...

anybody’s picture

No, please create a separate issue for that with further information about which condition is meant. This is just about boolean negation!