When I press 'create' button with nodereference explorer (creating a referenced node) the node doesn't have the og group audience checkbox.
Can't get og context as that's what actually missing.

Options:
1. It's a bug and needs to be fixed
2. If i had the referencing node nid, i could get $_GET['gids'][0] maybe.
3. If i can alter the url with the button 'create' I could put gids into the url.
4. Can I create my own button that i can use instead of current 'create' button?
5. can we mix the functions with nodereference url.
6. Am i at the right direnction??

Are there any other options?

Anyone has any solution for this please?

Comments

bsandor’s picture

Some further thoughts:

  1. I can change the link in function nodereference_explorer_widget_process($element, $edit, $form_state, $form) So I can pass a node id this way.
    If i do it my modalframe doesn't work.
  2. Programatic solution? Passing node id to the form that is function nodereference_explorer_create_node($dialog_api, $type_name, $field_name, $new_type = NULL) or function nodereference_explorer_form_alter(&$form, $form_state, $form_id) if I am right.
    I can't see where these functions were called so I can't pass any arguments to either.

It's a pretty complicated situation as of modules used.

Is there anyone who have some further ideas?

bsandor’s picture

hook_form_alter solves the problem half. With it i could insert previous group context onto my form. However i still don't have my full or proper integration with other modules.

I think group context needs to be set up earlier than hook_form_alter during form building process.

Anyways I used similar to following code in form_alter, it might be enough for someone:

case 'myformname_node_form': {
og_set_group_context (node_load($_SESSION['og_last']));
$form_state['og_gids'][0] = og_get_group_context () -> nid;
break;
}

bsandor’s picture

Status: Active » Needs review

Instead of using hook_form_alter I modified nodereference_explorer.widget.inc: function nodereference_explorer_widget_process:

Changed line:
'create' => url(NODE_REFERENCE_EXPLORER_MENU_CALLBACK_CREATE .'/' . $field['widget']['dialog_api'] .'/'. $type_name .'/'. $field_name),

to:
'create' => url(NODE_REFERENCE_EXPLORER_MENU_CALLBACK_CREATE .'/' . $field['widget']['dialog_api'] .'/'. $type_name .'/'. $field_name, array ( 'query' => 'gids[]=' . og_get_group_context() -> nid ) ),

Now my system seems to be compatible with all my other modules as nodecreation process has OG gid.

gnindl’s picture

Status: Needs review » Fixed

Committed your proposal of #3 to the repository. Added additional checks if OG module is installed.

http://drupalcode.org/project/nodereference_explorer.git/commit/0075385

Status: Fixed » Closed (fixed)

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