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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

makara’s picture

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

Ryan Palmer’s picture

Project: Context » Internationalization
Version: 6.x-2.0-beta7 » 6.x-1.x-dev
Component: Code » Experimental modules

Ok, 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

Ryan Palmer’s picture

Project: Internationalization » Context
Version: 6.x-1.x-dev » 6.x-2.0-beta7
Component: Experimental modules » Code

Does this type of plugin belong with the Context module itself? If so, how best to integrate this code?

jmiccolis’s picture

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

Ryan Palmer’s picture

Project: Internationalization » Context
Version: 6.x-1.x-dev » 6.x-2.0-beta7
Component: Experimental modules » Code
FileSize
574 bytes

Here'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.

xmacinfo’s picture

I'd love to see this in the main Context module.

Ryan Palmer’s picture

Status: Active » Needs review
FileSize
1.2 KB

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

mrfelton’s picture

subscribing.

mrfelton’s picture

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

Ryan Palmer’s picture

Yeah, I wouldn't use my patch just yet. Use the patch here instead.

svendecabooter’s picture

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

svendecabooter’s picture

Nevermind, I applied this patch http://drupal.org/node/657710#comment-2376254 and that fixed my problem. Hopefully this'll get in.

perandre’s picture

Replacing the url logic with context based display on i18n sites ftw. Will test!

yhahn’s picture

Version: 6.x-2.0-beta7 » 6.x-3.0-alpha2
Assigned: Unassigned » yhahn
FileSize
2.55 KB

I'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.

yhahn’s picture

Status: Needs review » Fixed

Test added, committed to 3.x: http://drupal.org/cvs?commit=326172.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

haggins’s picture

Status: Closed (fixed) » Active

Will this feature get into 2.x as well?

Steven Jones’s picture

Status: Active » Closed (fixed)

I'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.