Question

setRedirect doesn't works in the model file of a component.

models->test.php

$this->setRedirect(JRoute::_('index.php', false));
Was it helpful?

Solution

In Joomla 2.5 and Joomla 3.0

Redirection inside a model file:

$app = JFactory::getApplication();
$app->redirect(JRoute::_(JURI::root().'index.php'));

This redirection works in all files inside joomla, But the better way is to use in controller file is the below one.

Redirection inside a controller file:

$this->setRedirect(JRoute::_('index.php', false));

In Joomla 1.6 and 1.7 use this for redirection inside model file:

global $mainframe;
$mainframe              =& JFactory::getApplication();
$mainframe->redirect($url, JText::_('Your Mail sent') );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top