Alternative to drupal_goto()

beautifulmind - February 9, 2008 - 06:55

Is there any alternative to drupal_goto() other than form['#redirect'] for redirecting users?

Thank you.

why do you want an alternative?

Christefano - February 9, 2008 - 09:15

If this isn't for a module, you can always send users off somewhere by giving them something like header("Location: $url"); where $url is a URL that's been sanitized.

If you are writing a module you can copy drupal_goto() into the module and change the "drupal" part to the name of your module. Take a look at the current dev versions of Coral Defender or Path Redirect module for an example.

As per (our) coding standard...

beautifulmind - February 9, 2008 - 10:30

I am writing a module and I have studied both the modules you suggested. Thank you for your suggestion.
As per our coding standard, we don't allowed to use drupal_goto(), but now the we are allowed to user it.
Thank you very much for your warm response.

Beautiful mind
Know more

Form redirects?

Heine - February 9, 2008 - 10:44

Is this by any chance about redirecting after form submission? Only then does the coding standard about not using drupal_goto make sense.

Simply return the desired path as a string from your submit handler. If you need to redirect to a more complex url (with query/fragment), return an array with $path, $query, $fragment.

--
The Manual | Troubleshooting FAQ | Tips for posting | How to report a security issue.

Not form redirects...

beautifulmind - February 9, 2008 - 10:51

Let me explain, by our coding standard I meant that our organization coding standard.
Its not form redirects but concerns with redirecting from some other custom functions in custom modules.

Thank you for your reply.

Beautiful mind
Know more

 
 

Drupal is a registered trademark of Dries Buytaert.