Context integration

Events happening in the community are now at Drupal community events on www.drupal.org.
swentel's picture

Spin of from http://drupal.org/node/1221892

I post some additional ideas:
- ds code support (condition/reaction)
- passing arguments to field (eg. block views) from a view result or ds code (as reaction)
- custom theming / layout switcher (reaction)
- hide / show a layout region

Use cases:
- node has term, display related nodes with term
- user has this role, display a layout-[$user->rid] layout
- user is going to buy a product, show the region with the related products he could be interested (based on cart or tracker as nid view arguments).

The idea is that this needs to be a separate project instead of DS core. Discuss further!

Comments

Generic Context API

netsensei's picture

A big problem is the lack of a generic context API in Drupal. If you would take care of support for the Context project, what about the Rules people?

Creating a totally separate project instead of implementing context project specific hooks in DS is a good idea.

The way context logic works is that it checks on specific events if a group of conditions is met before it triggers a reaction. The same paradigm applies to either Context, Rules or any other context module out there. The problem is that you still have to define these specific events in the main program flow as cues for a context module to do something.

Which leaves me with these three considerations:

1/ is the scope of the available hooks in DS broad enough for context modules to work their magic? There's always someone who's going to want to alter something which isn't accessible through a hook at runtime.

2/ what about module weights? Execution order might stir a bit of chaos here as events might not get registered in time, etc. In the past, I had rigged DS with a few invoke_event hooks to support Rules as a test. When you evaluate a condition which is related to another module (i.e. user) then you want that module code already executed before the event is triggered. Not after. Otherwise you end up with the curious situation where apparently your conditions evaluate to TRUE but the reaction doesn't get triggered.

3/ what about management? When assigning fields, etc. to view mode layouts and such, you are defining a static context. Nothing changes at runtime. When you want to dynamically display and remove fields at runtime, management through a UI increases in complexity. Just take a look at my VCD project: http://drupal.org/project/vcd You assign a DS Field row plugin to a view and assign a few view modes. With the context module, you can switch between view modes depending met conditions. Which are managed within the Context module. Given a dozen views, a few view modes and a enough differing use cases you will end up in configuration hell. No exceptions.

Doesn't mean we should go for it. I'm just wondering if we should wait for D8 before taking a look at this. At least a single API makes it less painful.

Hi, I agree with netsensei

muka's picture

Hi,
I agree with netsensei about how hard is managing a lot of context both with context module and rules.

I was thinking how to handle a cascading context set, based on more generic to less generic like "entity » node » field"
It could be something like a "context set" (like rules "rule set") storing settings for each single case (and context enabled module or hook) overraidable on a specific context (eg. conditions in context module).

Another way is how core "contextual links" module works, which has hook but works in it's own way.
Many information useful to determine a runtime context would be there but miss something like hooking an action (or "reaction")

Just some -confused- thought.. :)

Luca

Hi, I'm working on those

muka's picture

Hi, I'm working on those points (throught context.module):
- custom theming / layout switcher (reaction)
- hide / show a layout region

I'm using hook_entity_view to alter $entity->content['#view_mode'] with a condition/reaction settings
Actually seems it switch layout but not completely as some field (eg ds view block fields) aren't in $vars in ds_entity_variables and so in ds_render_region (ds.module) their skipped.

Ant hints?

Thank in advance
Luca

Another module for the mix

nedjo's picture

Context panels layouts, http://drupal.org/project/context_panels_layouts, includes the ability to use panels layouts in context, rather than needing to implement custom layouts in a theme.

I've just opened an issue to introduce Display Suite layouts support to Context panels layouts, http://drupal.org/node/1494624. Any hints, tips, or patches most welcome.

So let's move to the <a

yannickoo's picture

So let's move to the issue back please. I reopened it and posted a small summary what we need to do.

Display Suite

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: