Write your own component, or put the following code somewhere in the template, to execude it:
<?php
jimport( 'joomla.application.application' );
JApplication::redirect("index.php?anyparameterhere");
exit;
?>
Should redirect the browser to the new url
in the backend (template: isis) gives the error "using $this when not in object context".
I activated DEBUG and got this last line:
JROOT\libraries\legacy\application\application.php:380
There is this code:
if (count($this->_messageQueue))
When using JApplication without instanziating it as new class, this error is produced.
Perhaps this line 380 in libraries\legacy\application\application.php should be altered to check, if $this is an object, or use self::_messageQueue instead?
Or even better: give a more detailed error-message to the user, that says "Japplication cannot be used statically here, make an object first or use JFactory::getApplication"
Labels |
Added:
?
|
Category | ⇒ | Libraries |
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-08-25 11:35:59 |
Closed_By | ⇒ | mbabker |
Having the same problem. I think what was really asked here, was how is the proper way to call this redirect, not PHP basics. I would appreciate if you could show how to fix it or at least give a link to "Joomla breaking changes for version XXX->YYY" where this functionality was changed.
I think I found fix. Replace:
JApplication::redirect(...);
with
use Joomla\CMS\Application\CMSApplication;
(CMSApplication::getInstance('site'))->redirect(...);
I think I found fix
That is wrong fix. Use:
Joomla\CMS\Factory\Factory::getApplication()->redirect();
Since the method declaration doesn't contain the "static" keyword, it should be expected that a static method call wouldn't work correctly here. You're also getting a PHP generated message, not something Joomla is emitting.
Closing as expected PHP language behavior.