I created a context that simply checks the "OG Group Type" to determine if a node is posted in a group. The behavior I'm seeing isn't quite what I expected.

When viewing the group home page.... not seeing the blocks I enabled.
When viewing a view page (node/[group nid]/view_page_path)... I do see the blocks enabled.
When viewing a node posted to the group... not seeing the blocks I enabled.
When viewing group edit, broadcast, track tabs... I do see the blocks enabled.

I have the context_devel block displaying on every page... and my context is showing up under context_ui in all cases. I do not have any other contexts using the same attribute.

Comments

mstef’s picture

I'd call this a dupe of #854280: Context trigger doesn't work when a Panel overrides a Group node

Maybe we should just start with my 2.x branch and make it better?

caschbre’s picture

I'm not using panels and haven't changed the group home page. Very odd.

Which 2.x branch is yours? I'm using 6.x-2.0-beta1, should I switch to the dev?

caschbre’s picture

I switched to the latest 6.x-2.0-dev and still have the same issue.

marcp’s picture

There's probably a timing issue with regards to when the context gets set. If you guys could work together and try out my suggestion in comment 1 at #854280: Context trigger doesn't work when a Panel overrides a Group node that would be helpful.

caschbre’s picture

I think I figured it out...

The context_og_context_page_condition was working for view pages and the other tabs off of the group node. (the two working conditions in my original post).

I added a hook_nodeapi and performed the same logic as context_og_context_page_condition and was able to get it working on the other two conditions in my original post.

function context_og_nodeapi(&$node, $op, $teaser, $page) {
  if ($op == 'view' && $page && ($menu_ob = menu_get_object()) && $menu_ob->nid == $node->nid) {
    $group = og_get_group_context();
    if ($group) {
      context_set_by_condition('og_group_node', $group->nid);
      context_set_by_condition('og_group_type', $group->type);
    }
  }
}

Note: This code was simply a copy/paste to see if using hook_nodeapi worked... we'd probably want to make another function that contains this logic that both hooks can call.

marcp’s picture

Yeah, this is definitely about what I was hoping for.

Ideally we'd be able to put this code in context_og_init() and get everything working -- want to give that a try instead of in hook_nodeapi()?

caschbre’s picture

I'll see if I can get to it tonight.

caschbre’s picture

context_og_init did not appear to work.

It appears that the function og_get_group_context is not able to return anything in hook_init. Might be a module weighting if this is firing before og, but that's a guess.

marcp’s picture

@caschbre - I committed similar code to what you posted above and cut another beta. I suspect this fixes your issues.

@mikestefff - The code that I committed sets the context in all the same places that the node contexts set context. I'm hoping that this will work for you. There's one place in there that I don't really understand -- hook_ctools_render_alter() -- which I'm hoping will catch your Panels issue. If this doesn't work, then we can add in the call in hook_views_post_render().

caschbre’s picture

I'll take a look at it.

If it is any help, I'm working on a Context CCK module (http://github.com/caschbre/context_cck). It's on github until I can get a drupal cvs account. It's in very very early stages, but it is based on the Context 2.x module.

caschbre’s picture

beta2 looks good so far.

mstef’s picture

How's it going here...?

Can I help?

Did we fix anything?

mstef’s picture

Beta2 is looking good so far...looks like I'll ditch my custom thing and just use this..

On a side note: What's the current status with Context_og 3.x? Have these same issues been solved?

marcp’s picture

@mikestefff - The idea is that Context OG 3.x will work in the same instances -- it's working great for us now, but we don't use Panels. If you switch to 3.x and it's not working with Panels, or whatever, then let's open up a new issue and we'll get it fixed there.

marcp’s picture

Status: Active » Fixed

This looks to be fixed, so I'm closing it out. Please open up new issues as you find them.

Status: Fixed » Closed (fixed)

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