Hey,

Automodal is so fantastic I love it...but is there any way to redirect the user to their submitted node after submitting it? My users are complaining that they create something in modal and they have no idea how to see what they created.

Thanks!

Comments

rc2020’s picture

anyone?

rc2020’s picture

anyone, anything?

rc2020’s picture

FYI - I put a detailed support request in the modal frame API's issue queue: http://drupal.org/node/757686 The test of it is as follows:

I use modal frame API with automodal, and I'm trying for the life of me to redirect to the submitted node AFTER modalframe_close_dialoug(); is envoked. Now, if I try to initiate the redirect, it redirects to the submitted node however it redirects within the modal window.

I can get the redirect to happen a couple of ways. The first is by hacking the modalframe.module - line 204:


function modalframe_form_submit($form, &$form_state) {
  if (!empty($GLOBALS['modalframe_close_dialog'])) {
   //Change from FALSE to TRUE
    $form_state['redirect'] = TRUE;
  }
}

This forces the redirect, but it happens within the modal. I'm not sure where/how to call modalframe_close_dialog() before the $form_state['redirect'].

The other way is by adding the function within automodal, which is essentially just a helper module to load the modal frame window with drupals forms api.

function automodal_form_submit($form, &$form_state) {
  if ($form_state['values']['op'] == t('Save')) {
    // Tell the parent window to close the modal frame dialog.
    modalframe_close_dialog();
  }
}

Trying to call the $form_state redirect outside of this function is still possible in automodal's invocation for hook_form_alter(), but again, the redirect will happen in the modal, not after the modal has closed.



function automodal_form_alter(&$form, &$form_state, $form_id) {
    $form['#submit'][] = 'automodal_form_submit';
        //Add in redirect
    $form_state['redirect'] = TRUE;
}

Lastly, it is possible to initiate the redirect through rules.module, but, again, the redirect only happens within the modal - not after it has closed.
Even if I set a rules action to 'execute custom php code' and add in modalframe_close_dialog(), the redirect still happens in the modal window.

I've been banging my head against this for a while, is there anything anyone can suggest to achieve this? The usability of modal frames to add node forms is severely diminished if the user can't be redirected to what they submitted.

Thanks!

mfer’s picture

Status: Active » Fixed

There is now a property to use with automodal_add called automodalRedirect. See the docblock for that function. It can be a location you want to redirect to. If you need to alter that hook_automodal_close_args_alter provides that.

Status: Fixed » Closed (fixed)

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

broncomania’s picture

I run into the me problem. Can we get an example of how to use it? I try several things but I can't get it work to redirect after my form was submitted. I think hook_automodal_close_args_alter is not called but I am not sure if I use it correct. I think the automodal_add function is somehow broken.

broncomania’s picture

Category: support » bug
Status: Closed (fixed) » Active
gejo’s picture

Simply add automodalReload=true as a parameter in the URL for the links:

<a class="automodal" href="http://example.com?automodalReload=true>myLink</a>

You could do that with jquery:

$(document).ready(function() {
	$('a.automodal').each(function() {
	  var href = this.href;
	  if (href.indexOf('?') != -1) {
	  //if this URL has other parameters
		href = href + '&automodalReload=true';
	  }
	  else {
		href = href + '?automodalReload=true';
	  }
	  $(this).attr('href', href);
	});
});
dsnopek’s picture

Issue summary: View changes
Status: Active » Closed (fixed)

Works as designed per comment #4.