Skip to content

Instantly share code, notes, and snippets.

@rjmackay
Created May 20, 2011 14:58
Show Gist options
  • Save rjmackay/983085 to your computer and use it in GitHub Desktop.
Save rjmackay/983085 to your computer and use it in GitHub Desktop.
Add gids parameter to node/XXX/edit urls - so noderelationships has context
/*
* Implementation of hook_nodeapi()
* Add gids parameter to node/XXX/edit urls - so noderelationships has context
*/
function og_country_nodeapi(&$node, $op) {
if ($op != 'prepare') return;
if (!empty($_REQUEST['gids'])) return;
if (arg(2) == 'edit' && $node->og_groups) {
unset($_REQUEST['destination']);
drupal_goto(
arg(0).'/'.arg(1).'/'.arg(2),
drupal_query_string_encode(
array_merge($_GET, array('gids' => $node->og_groups)),
array_merge(array('q', 'destination', 'pass', 'translation', 'language'), array_keys($_COOKIE))
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment