Introduction to the method of modifying successful and failed jump pages in TP3.1.x

黄舟
Release: 2023-03-16 14:04:02
Original
1928 people have browsed it

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);
  }
}
?>
Copy after login

There is a SucErr folder in Tpl, There is index.html as follows:


<!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=&#39;__APP__/SucErr/success1&#39;">成功页面</button>
  <button onclick="javascript:window.location.href=&#39;__APP__/SucErr/error1&#39;">错误页面</button>
</body>
</html>
Copy after login

There are only two buttons to display the prompt page of success and failure. The prompt page will automatically jump after only 3 seconds. change.

Please note that in

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!