Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Joomla setRedirect doesn't work

I have a simple Joomla controller, but I can't redirect anything.

According to the documentation:

class MyController extends MyBaseController {

 function import() {
    $link = JRoute::_('index.php?option=com_foo&ctrl=bar');
    $this->setRedirect($link);
  }

}
//The url contains & html escaped character instead of "&"

This should work, but I get a malformed URL. Is there something I'm missing here? Why is Joomla converting all the "&" characters into &'s? How am I suppose to use setRedirect?

Thank you

like image 532
Opi Avatar asked Feb 20 '26 03:02

Opi


1 Answers

Alright, I fixed it. So if anyone needs it:

instead of

$link = JRoute::_('index.php?option=com_foo&ctrl=bar');
$this->setRedirect($link);

use

$link = JRoute::_('index.php?option=com_foo&ctrl=bar',false);
$this->setRedirect($link);

to make it work.

like image 68
Opi Avatar answered Feb 22 '26 00:02

Opi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!