开发者

joomla setRedirect

开发者 https://www.devze.com 2023-01-29 16:08 出处:网络
How to prevent executing code after setRedirect? I\'ve place setRedirect in co开发者_JAVA百科ntroller, it does redirect to different controller but still executing rest of the code in first controlle

How to prevent executing code after setRedirect?

I've place setRedirect in co开发者_JAVA百科ntroller, it does redirect to different controller but still executing rest of the code in first controller.


Usually "redirect" will return "exit()", but "setRedirect" return "void()".

$application = JFactory::getApplication();
$application->enqueueMessage(JText::_('MSG'), 'Warning');
$application->redirect('index.php?option=com_rooms&task=schedule&view=schedule');


like @biswarupadhikari's example, but more J! like with close() method:

$app = JFactory::getApplication();
$app->redirect('index.php?option=com_component');
$app->close();


Use php die() function after setRedirect, it's equivalent to exit()


Use like this way

$mainframe=JFactory::getApplication();
$mainframe->redirect("index.php?option=com_test&task=othertask","Redirected to other task");
exit(0);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号