Hi,

Is there a way to redirect a user to a particular page when closing the modal window.
My use case is the following :

  • on homepage, user clicks a login link that opens a login/register modal window.
  • in case of login : after entering its credentials, modal window displays "you are now logged-in bla bla". When user closes the window, he is redirected to its user account.
  • in case of registering : after entering the required info, modal window displays "you account has been created bla bla". When user closes the window, he is redirected to its user account.

Thanks in advance

Laurent

Comments

daffie’s picture

Hi Laurant,

For reloading the page after closing the modal window

  $commands[] = ctools_ajax_command_reload();

For redirecting the page after closing the modal window

  $commands[] = ctools_ajax_command_redirect('your-link');

For sending an alert to the user

  $commands[] = ajax_command_alert('Your alert message.');

In the ctools_ajax_sample module you place the reload command in the following place

    $commands = array();
    if ($output === FALSE || !empty($form_state['complete']) || !empty($form_state['cancel'])) {
      // If cancelling, return to the activity.
      $commands[] = ctools_modal_command_dismiss();
      $commands[] = ctools_ajax_command_reload();
    }
    else {
      $commands = ctools_modal_form_render($form_state, $output);
    }
    print ajax_render($commands);
    exit;

Hope this helps you

merlinofchaos’s picture

Oh interesting. The ctools_ajax_command_* should do the add_js so you don't have to.

I don't suppose you'd be willing to put in a patch for this?

daffie’s picture

@merlinofchaos:

Does your response not belong to issue http://drupal.org/node/1485964?

I am not sure where you want to include

  ctools_add_js('ajax-responder');

Do you want to include it once in the ctool/includes/ajax.inc file or with every command in that file or do you have an other solution in mind?

daffie’s picture

Status: Active » Needs review
StatusFileSize
new1.41 KB

@merlinofchaos

The patch you requested.

daffie’s picture

Category: support » bug
agence web coheractio’s picture

Many thanks daffie.

merlinofchaos’s picture

Status: Needs review » Fixed

Thanks for hte patch! Committed and pushed.

Status: Fixed » Closed (fixed)

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

mallikarjunvh’s picture

hi,
can u please tell me where to add this code( in .module file or some where else)
lots of thanks

daffie’s picture

@m_arjun

In the .module file. You can also use an other file. That a look at the ctools_ajax_sample module. It is included in the ctools module. The file is called ctools/ctools_ajax_sample/ctools_ajax_sample.module.