Create group content block:

I want the user to see his/her created node just after saving. But instead, it returns to the page where the link is clicked.

At the end of the links, there is &destination=node/1234 parameter which redirects to that page. How can I remove it?

Comments

eojthebrave’s picture

In oder to do this you would need to override og-extras-group-links.tpl.php file and replace the $group_node_links variable with a new site of links. Which you can get by calling the og_node_create_links() from the og module and using a different destination parameter. You can you see how we do it in this module, the code is in og_extras_node_links().

Let me know if that works for you.

bnicoll’s picture

Having a very similar issue - #1838822: Create content stays on same page

Any help would be much appreciated

Ben.

bnicoll’s picture

Was hoping you could clarify this a little bit - how I might be able to modify OG_Extras so that it will continue through to the newly created node after creating new content.

Thanks in advance.
Ben.

eojthebrave’s picture

I started to look in to ways to make this configurable. Like a checkbox that would allow the site admin to choose if these links should redirect to the current page, the new page or the group page ... however the og_node_create_links() function has some issues.

#1848028: The $destination paramater for the og_node_create_links function is not used

bnicoll’s picture

Thanks for e-mail - I'll get this patch in it's probably a little nicer than my commenting out workaround.

I had simply modified organic groups module directly. - og.module

Around line 3030 I simply commented out the ', + drupal_get_destination(), ' and it now works just fine.

// Build links.
$options = array(
'query' => array($field_name => $gid)// , + drupal_get_destination(),
);

Thanks,
Ben.

eojthebrave’s picture

Did you get this sorted out? Want to provide a patch for this?

Patrick Danielsson’s picture

I can't seem to get this function to work, any ideas?

In og.module, my code looks like this, is there another way I can modidy to remove the destination?

// Build links.
  $options  = array(
    'query' => array($field_name => $gid),
  );

  if ($destination) {
    $options['query']['destination'] = $destination;
  }
  else {
    $options['query'] += drupal_get_destination();
  }
tmctighe’s picture

Issue summary: View changes

Not really the best method, but this worked for me:

/**
 * Implements hook_block_view_alter()
 *
 * @param (array) $data - data returned from hook_block_view()
 * @param (stdClass) $block - block object strait from the DB
 */
function mymodule_block_view_alter(&$data, $block) {
  if ($block->bid == 'og_extras-node_links') {
    $data['content'] = preg_replace('/&destination=node\/\d+/i','',$data['content']);
  }
}
mygumbo’s picture

In og_extras.module:
$content = og_node_create_links($group['group_type'], $group['gid'], OG_AUDIENCE_FIELD, NULL, $types);

Changing the 4th arg from NULL to FALSE will suppress the destination from the link.