This article mainly introduces the method of modifying the successful and failed jump pages in ThinkPHP3.1.x, involving the setting and modification operation skills of the relevant jump codes in the underlying source files of thinkPHP. Friends in need can refer to the following
The example of this article describes the method of modifying the successful and failed jump pages in ThinkPHP3.1.x. Share it with everyone for your reference, the details are as follows:
In ThinkPHP, success and failure prompt pages are already included. Just call it automatically in the Action method.
For example, there is the following SucErrAction.class.php in Lib\Action:
##
<?php class SucErrAction extends Action{ public function index(){ $this->display(); } public function success1(){ $this->success("成功提醒!",U("SucErr/index"),3); } public function error1(){ $this->error("错误提醒!",U("SucErr/index"),3); } } ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>成功与错误页面</title> </head> <body> <button onclick="javascript:window.location.href='__APP__/SucErr/success1'">成功页面</button> <button onclick="javascript:window.location.href='__APP__/SucErr/error1'">错误页面</button> </body> </html>
SucErrAction.class.php, you cannot define the success method and error method yourself. These are inherent methods in the system's Action abstraction. Declare the success method and error method. The method is to override after inheritance, which will make ThinkPHP run normally.
However, the success and failure prompt pages that come with the system cannot meet the needs of the website. But this page can be modified by yourself, such as the above In the picture, I added a little text to the jump page of success and failure. The specific location of this page is:.\ThinkPHP\Tpl\dispatch_jump.tpl
I will write some words on line 18 to achieve the picture above As a result, you can write any front-end language according to your needs on this page. The$this->success() or
$this->error() will jump in the ThinkPHP method. Go to this page.
The above is the detailed content of Introduction to the method of modifying successful and failed jump pages in TP3.1.x. For more information, please follow other related articles on the PHP Chinese website!