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.
I think it makes sense to expose languages as an available condition to specify context by.
Files attached.
May or may not be entirely useless given that context doesn't seem to allow the use of an "AND" operator for testing conditions. I could be wrong.
Comment | File | Size | Author |
---|---|---|---|
#14 | context_condition_language.patch | 2.55 KB | yhahn |
#7 | context-language-632322.patch | 1.2 KB | Ryan Palmer |
#5 | language_context.tar_.gz | 574 bytes | Ryan Palmer |
i18ncontext.tar_.gz | 599 bytes | Ryan Palmer |
Comments
Comment #1
makara CreditAttribution: makara commentedHmm.. no, this is more like a plugin to Context. Given the name "i18ncontext" it should give the ability to "translate" a context. That says, for a specific set of conditions, in different language, display different content. But that would be too complex.
BTW: I'd like to see something like "sub-context", which can make this useful.
Comment #2
Ryan Palmer CreditAttribution: Ryan Palmer commentedOk, its inclusion in i18n is indeed questionable.
Regardless, I was made aware of a way to use this, effectively making the language condition AND other conditions required for the context to exist. It has to do with how you name the contexts. If you make two contexts, for example, both sharing the same first two keys (Namespace and Attribute), only one context (with a unique Value) within that combined namespace will be active at any given time.
Example:
Namespace Attribute Value
foo bar english
foo bar french
Comment #3
Ryan Palmer CreditAttribution: Ryan Palmer commentedDoes this type of plugin belong with the Context module itself? If so, how best to integrate this code?
Comment #4
jmiccolis CreditAttribution: jmiccolis commented@Ryan Palmer, I haven't had the chance to look at your code yet, but I think that this does indeed belong in the context module.
Comment #5
Ryan Palmer CreditAttribution: Ryan Palmer commentedHere's an updated module tarball reflecting the name change. For now it's a standalone module, but I could roll this into a patch to context_contrib if necessary.
Comment #6
xmacinfoI'd love to see this in the main Context module.
Comment #7
Ryan Palmer CreditAttribution: Ryan Palmer commentedOk. Patch attached.
One small caveat: it's a mostly useless addition to Context at the moment, only really useful as a replacement for i18nblocks. Since Context conditions can't be "required" necessarily, it's not possible to set a context based on node type "event" AND language French, for example, contrary to what I described above.
----
This patch is contributed by TP1 Internet 360, a Montreal-based Drupal web studio.
Comment #8
mrfelton CreditAttribution: mrfelton commentedsubscribing.
Comment #9
mrfelton CreditAttribution: mrfelton commented@Ryan Palmer: How do you see this being used as a replacement for i18n blocks? I have two translations of a block and I want to show a different one on page x depending which langiage of the site is currently active. As far as I can tell this isn't possible, even with your patch. Have you managed to get such a thing working?
Comment #10
Ryan Palmer CreditAttribution: Ryan Palmer commentedYeah, I wouldn't use my patch just yet. Use the patch here instead.
Comment #11
svendecabooterRegarding the block translation issue, wouldn't it be possible to add a check on the block language (if i18nblocks module is installed) in context_block_list() ?
So if a block has another language assigned than the currently active language, don't let context render it...
That would fix the problem that contexts can't have AND operations...
Comment #12
svendecabooterNevermind, I applied this patch http://drupal.org/node/657710#comment-2376254 and that fixed my problem. Hopefully this'll get in.
Comment #13
perandre CreditAttribution: perandre commentedReplacing the url logic with context based display on i18n sites ftw. Will test!
Comment #14
yhahn CreditAttribution: yhahn commentedI've implemented AND/OR of conditions in 3.x (http://drupal.org/cvs?commit=326160) and have ported this patch to 3.x as well. I need to write a condition test for it but once that's done I hope to commit it.
Here is the current patch for 3.x.
Comment #15
yhahn CreditAttribution: yhahn commentedTest added, committed to 3.x: http://drupal.org/cvs?commit=326172.
Comment #17
haggins CreditAttribution: haggins commentedWill this feature get into 2.x as well?
Comment #18
Steven Jones CreditAttribution: Steven Jones commentedI'm inclined to say no.
If you really want to have this condition, write a contrib module for 2.x, or help out with getting context 3.x stable.