Table of Contents

setRedirect

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage Application Class JController Method setRedirect Reference setRedirect() Never Work in Progress

Sets a URL for browser redirection.

A message and message type can optionally be specified. The message is displayed on the target page, and the message type determines which icon is displayed with the message.

Syntax

void setRedirect ( $url, $msg, $type )

$url string is a string containing the URL to redirect to.
$msg string is a string containing the message to display on redirect. This parameter is optional and if omitted defaults to the value that is internally set by the controller, if any.
$type string is a string containing the message type. This parameter is optional and if omitted efaults to ‘message’.

Examples

Example

if (JRequest::getVar( 'testvalue' ) != 1) {
	$controller->setRedirect( 'index.php?option=com_weblinks&testvalue=1&view=weblinks' );
	$controller->setMessage( 'This is the redirect message!' );
	$controller->redirect();
}

will result in the browser being redirected and the specified message being displayed at the top of the target page.