I'm trying to figure out how to accomplish the following, any help would be really apprecaited (or someone saying "that's not possible" so I stop trying :)
On every site I build I have a sitewide context which includes things like main navigation menu, footer information, etc. Stuff that should show on every page. I then want to set a 'fallback' or default context to use whenever there's no other contexts active except for the sitewide.
Now, I know I can do a default context by putting in a context condition of ~* (which means, not any other contexts are active). The problem is, the sitewide context is ALWAYS active, so that will never return true.
So, how can I put in a condition that says "there are no context active besides the sitewide context"? Or, to put it another way: "my sitewide context is the only active context".
Doing this will allow me to have a default context that is in effect when no other 'real' (ie. not sitewide) contexts are active.
Thoughts on accomplishing this?
Comment | File | Size | Author |
---|---|---|---|
#10 | context-default-condition-1018834-10.patch | 3.16 KB | fearlsgroove |
#8 | context_condition_path-1018834-8.patch | 782 bytes | ttkaminski |
#7 | context-default-condition-1018834.patch | 3.16 KB | fearlsgroove |
#6 | context_condition_default-1018834-6.patch | 1.92 KB | fearlsgroove |
#3 | context_condition_default.patch | 3.1 KB | fearlsgroove |
Comments
Comment #1
Maciej Lukianski CreditAttribution: Maciej Lukianski commented+1 I am just looking for the same thing.
So far I acomplished this by placing sitewide blocks in regions using the default block system. The deafault context than works providing default blocks for all situations where no specific context is present.
This way I cover all 3 secenarios:
1. I have sitewide blocks like Login or Navigation present all the time no matter what
2. I have blocks from custom contexts for specific areas - ie users comments blocks on user pages, latest articles blocks in news area, etc.
3. If by accident or design I do not define a context for an area of the site - say groups or some views pages, I am not left with just Login/Navi, because a get a bunch of blocks from the default context that fill the sidebar also engaging the user.
In my opinion, the default context should ignore the sitewide context by default. This way the 3 step scenario could be achieved solely via context. Or does it ignore it somehow, and I just don't know how to turn it on?
Comment #2
Maciej Lukianski CreditAttribution: Maciej Lukianski commentedOk, never mind.
If you set a sitewide context and default context with different attributes, the default context presents itself along the sitewide context.
The default is default for the attribute. If you have contexts with other attributes, they will show alongside the default one.
Comment #3
fearlsgroove CreditAttribution: fearlsgroove commentedI've had the same requirement on enough sites that I built a condition that deals with this. It works similar to sitewide, except that it will only be active if no other context with a condition other than sitewide or default is active. This allows precisely the scenario outlined by the OP: A sitewide context supplying things like footer menus, plus a "default" context that provides blocks if no other context does so.
Comment #4
fearlsgroove CreditAttribution: fearlsgroove commentednr
Comment #5
xmacinfoIs there a way to achieve this (#3) in template.php until it's available in the Context module?
Or in a custom module?
Comment #6
fearlsgroove CreditAttribution: fearlsgroove commentedSlight update changes the behavior such that the default context applies if:
1. there are no other contexts active OR
2. Any other active contexts have either a default condition or a sitewide condition.
Previously if other active contexts had any condition other than default or sitewide, they would prevent the default context from applying, which I found too restricting.
Comment #7
fearlsgroove CreditAttribution: fearlsgroove commentedHere's a reroll of #6 including the new file, which was missing. I'm surprised this hasn't gotten any more traction - I use this feature on just about every site I build ...
Comment #8
ttkaminski CreditAttribution: ttkaminski commented#7 patch works well. I am also surprised that this issue hasn't gotten much attention. I just started using Context for the first time, and I immediately ran into this issue. Before finding your patch, I implemented a fix to the core Context Condition by accepting full blown regular expressions in the patterns. My site wide context is named
global
and so my regex pattern in thedefault
context was:~#^(?!global).*$#i
Basically, the above pattern is saying to disable the current (default) context for any other context while ignoring
global
. The small patch enables regular expressions, and it's detected for any line that starts with # (PCRE delimiter). I chose this instead of forward slash because it's probably less likely a # would be in a path or context name. ~ (not operator) is still supported.The downside to this approach is that you need to know regular expressions. The upside is that you don't need to write a plugin for every special case.
Comment #9
micromegas CreditAttribution: micromegas commented#7 works as advertised; RTBC.
Comment #10
fearlsgroove CreditAttribution: fearlsgroove commentedWhitespace only reroll .. leaving RTBC
Comment #12
colanThanks!