Monday, December 29, 2014

[Joomla!][Resolved] joomla redirect feature doesn't not work after save.

When i click the "Save" button in a joomla administrator component, it's able to submit form but get <script>alert('');window.history.go(-1);</script> as response only. (redirection feature doesn’t work after save the data to database. )

These 4 lines is the related code:


According from the answer in stackflow, Joomla does not support something like that but Javascript does:

 window.history.back()

Change the code which echo JavaScript to html webpage to use joomla setRedirect() to make redirection. This is the original code:
if (!$db->store()) {
    echo "<script>alert('".$row->getError()."');window.history.go(-1);</script>\n";
    exit();
}
to
if (!$db->query()) {
    $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
    $this->setRedirect($url);

    exit();
}
Reference:
http://stackoverflow.com/questions/12948109/return-to-previous-page-in-joomla

No comments :

Post a Comment