Hey - this is a cool module and almost just what I was looking for ;-) You're saying this would be great for panel pages. I think so too, the only thing that bothers me is that after I create a node, I get redirected to the new node. But if I was gonna use it on a panel which, say, also displays a View of nodes - I would wanna create the node on that same panel and after node creation get redirected back to that panel with my View, only now with the new node in it.

Any ideas on how to accompolish that? Maybe by adding drupal_get_destination to the save button? http://api.drupal.org/api/function/drupal_get_destination

Comments

nedjo’s picture

This could be done by registering a #submit callback to the form and, in the callback, setting the destination to the current location:


$_GET['destination'] = $_GET['q'];

Or perhaps by adding a #redirect to the form?

aschiwi’s picture

And how would I add anything to a form, if it's a node/add form in a block? I have no idea where to start looking...

aschiwi’s picture

With the help of a friend I created a mini module which gets the current location and redirects you back to where ever you created the node from.

<?php
// $Id$
 
/**
* @file
* Redirects some forms after submission to other pages than default.
*/
 
/**
* Implementation of hook_form_FORM_ID_alter().
*
* Redirect guestbook_item node form after submission.
* @param $form
*   Form to be altered.
* @param $form_state
*   A keyed array containing the current state of the form.
* @return None.
*/


function formredirects_form_CONTENTTYPENAME_node_form_alter($form, &$form_state) {
  $form['#redirect'] = $_GET['q'];
  
  // Remove status message ("node has been created...").
   unset($_SESSION['messages']['status']);
}
?>
aschiwi’s picture

Status: Active » Closed (fixed)
aschiwi’s picture

Project: Formfilter » Form Block
Version: 6.x-1.x-dev » 6.x-1.0

Oh man, I just saw this is posted in the wrong module issue queue! I meant to post this in the formblock queue, I'm gonna try to change the project on this :-(

radiorel’s picture

In case anyone's looking for a way of doing this without getting too deep into code, this can also be achieved using the Rules module and setting up an 'after saving new content' rule on a particular content type that redirects to a custom page.

trevorfoulk’s picture

i'm using form block and having this exact problem - when the user creates a new node, i want to go back to the page the user created the node on, not the new node.

i am a pretty experienced php programmer but new to drupal - can someone give me some help with context here - where do I put this code in order to make this work?

thanks

Makku01’s picture

@ aschiwi: the redirect of the form works fine, but what if I only want to redirect if the form is submitted via formblock module? The default node_edit form should not redirect to a specific destination. Any ideas? Thanks