OG adds automatically destination parameter to content create links if you use Panels plugin. In some cases it would be needed to remove that destination so that user could be redirected to a new node page after submitting the node add form.

Here is a patch for it. It has been made against the latest release 7.x-2.4.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vaartio’s picture

vaartio’s picture

Okay, I found the issue Can't unset og_node_create_links destination just a day after my post. It does not solve the problem if you use create links Panels plugin but gives a possibility to unset destination in other cases.

Basically the patch above remove the effect of #1983450 so I decided to modify my suggestion a bit. Attached is a patch that changes the behavior of og_node_create_links_content_type_render method only. It sets destination to FALSE if redirection is not selected on content create links edit form.

However, the current implementation of og_node_create_links method can be considered a bad API design:

  • if destination is a string it will be used as destination parameter
  • if destination is FALSE destination is not set at all
  • if destination is NULL (which is the default value) Drupal drupal_get_destination() is used

It would be much more simpler and clearer to add destination only if it is passed as a parameter, as originally suggested on #1983450.

amitaibu’s picture

Status: Active » Needs review

Correct status

The last submitted patch, 1: og-optional-create-links-destination-2159073.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 2: og-optional-create-links-destination-2159073-2.patch, failed testing.

The last submitted patch, 1: og-optional-create-links-destination-2159073.patch, failed testing.

The last submitted patch, 2: og-optional-create-links-destination-2159073-2.patch, failed testing.

amitaibu’s picture

Version: 7.x-2.4 » 7.x-2.x-dev
Status: Needs work » Needs review

... and correct version.

amitaibu’s picture

ranroz’s picture

Works well and seems ok.
I made a few small cleanup changes.

amitaibu’s picture

Status: Needs review » Needs work
  1. +++ b/plugins/content_types/node_create_links/node_create_links.inc
    @@ -24,8 +25,11 @@ function og_node_create_links_content_type_render($subtype, $conf, $args, $conte
    +  // Set destination to FALSE to prevent on using destination at all. Otherwise use default value (NULL).
    

    Comment should be on 80 chars.

  2. +++ b/plugins/content_types/node_create_links/node_create_links.inc
    @@ -24,8 +25,11 @@ function og_node_create_links_content_type_render($subtype, $conf, $args, $conte
    +  $destination = !empty($conf['redirect']) ? NULL : FALSE;
    

    Looking at this I believe we need to change og_node_create_links() - either import the docs, or change the $destination argument.

ranroz’s picture

Added better documentation for og_node_create_links() to distinguish better between the use cases of the function.

amitaibu’s picture

I think you uploaded wrong patch. Also set status to "needs review"?

ranroz’s picture

Status: Needs work » Needs review
FileSize
2.83 KB

@amitaibu - Updated patch and status.

amitaibu’s picture

Status: Needs review » Needs work
(optional) The destiantion after a node is created. If NULL, destination is
set to the one passed in the URL if exists (default case). If is a string
it will be used as the destination. If FALSE no destination will be set
for the node create links.

destiantion => destination

Also I think the docs are a good start but needs a little cleanup. Maybe:

(optional) The destination to redirect the user after the node is created. possible values:
- NULL: If destination is set in the URL (e.g. example.com/node/add/group?destination=foo) If NULL, the destination is used. This is the default behaviour.
- FALSE: ...
mccrodp’s picture

Status: Needs work » Needs review
FileSize
2.86 KB

I updated the patch with your comment recommendations.

MsArk’s picture

#16 Works well. I tried it in version 7.x-2.9. Thanks