Posted by rukshilag on March 12, 2010 at 2:27pm
I am doing a system in drupal - and i am also coding in php in the drupal pages i create to connect to a database and display results for various requirements.
How do you redirect a certian page to another page in drupal?
do we use the node number or what?
edited by silverwing - changed forum
Comments
Writing custom code in your
Writing custom code in your content (nodes) is not recommended - I would even say: strongly discouraged.
A powerful and flexible CMS like Drupal is built on the separation of content, behavior and presentation. When you start scripting (behavior) in nodes (content), you are crossing those borders. Although it can work without errors, you will end up with a less flexible, worse performing and possibly less secure site. Also, it will be harder to extend your site with contributed modules and it will be harder for the community to help you when something goes wrong.
If you want/need to write custom code for Drupal, the best way is to write a module. However it is very likely that existing modules already offer what you're looking for. I invite you to tell us what you're trying to achieve, so we can help you find the best solution for your problem.
Redirect via PHP
The code below is an example of what you would use to redirect from one node to another within your site.
<?phpheader ('HTTP/1.1 200 OK');
header ('Location: /node/204');
?>
To redirect to another site, the following example would work.
<?phpheader ('HTTP/1.1 200 OK');
header ('Location: URL');
?>
"URL" would be something such as http://espn.com.