开发者

joomla setRedirect

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜