Home PHP Framework ThinkPHP ThinkPHP custom success and error jump pages

ThinkPHP custom success and error jump pages

Mar 07, 2020 am 10:34 AM
thinkphp customize Jump page

This article introduces the method of customizing success and error jump pages in thinkphp5. It has certain reference value. I hope it will be helpful to friends who are learning the thinkphp framework!

ThinkPHP custom success and error jump pages

ThinkPHP custom success and error jump page

The jump template settings defined in thinkphp5 are in the directory It is defined by application\config.php and also defines the jump template file by default. The following is the code in config.php.

// 默认跳转页面对应的模板文件
    'dispatch_success_tmpl'  => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
    'dispatch_error_tmpl'    => THINK_PATH . 'tpl' . DS . 'dispatch_jump.tpl',
Copy after login

(Recommended tutorial: thinkphp tutorial)

With the above definition settings, we can quickly find the actual location of the default template, in the core file directory thinkphp\tpl \dispatch_jump.tpl. First, we want to customize the jump template file. We have two ideas. The first idea is that the template file should not be set, that is, delete the original content of the above thinkphp\tpl\dispatch_jump.tpl file and change it to Our own file contents. Another way of thinking is that we redefine the location of the jump file. We usually redefine dispatch_success_tmpl and dispatch_error_tmpl in the config folder under which project we need to jump. Here I take the admin project as an example. Its configuration file application\admin\config.php is defined as follows

<?php
//配置文件
return [
  //分页配置
  &#39;paginate&#39;               => [
      &#39;type&#39;      => &#39;bootstrap3&#39;,
      &#39;var_page&#39;  => &#39;page&#39;,
      &#39;list_rows&#39; => 15,
  ],
    // 默认跳转页面对应的模板文件
  &#39;dispatch_success_tmpl&#39;=>&#39;public:dispatch_jump&#39;,
  &#39;dispatch_error_tmpl&#39;=>&#39;public:dispatch_jump&#39;,
  // &#39;dispatch_success_tmpl&#39;  => THINK_PATH . &#39;tpl&#39; . DS . &#39;dispatch_jump.tpl&#39;,
  // &#39;dispatch_error_tmpl&#39;    => THINK_PATH . &#39;tpl&#39; . DS . &#39;dispatch_jump.tpl&#39;,
];
Copy after login

After the above definition and setting, the jump template file is in application\admin\view\public\dispatch_jump.html , the above is the setting method of thinkphp5, but thinkphp3.2 is different from this. The template path in 3.2 is different. If you want to set it up separately in a certain project directory, you must first create the conf folder and then create config in it. .php file, the following is the code of the default settings file in ThinkPHP\Conf\convention.php

  /* 模板引擎设置 */
    &#39;TMPL_CONTENT_TYPE&#39;     =>  &#39;text/html&#39;, // 默认模板输出类型
    &#39;TMPL_ACTION_ERROR&#39;     =>  THINK_PATH.&#39;Tpl/dispatch_jump.tpl&#39;, // 默认错误跳转对应的模板文件
    &#39;TMPL_ACTION_SUCCESS&#39;   =>  THINK_PATH.&#39;Tpl/dispatch_jump.tpl&#39;, // 默认成功跳转对应的模板文件
Copy after login

The last thing to note is that if the smart template engine is used, the For this, we just replace it with {$jumpUrl}. If it is thinkphp5, just change it to {url}.

For more thinkphp tutorials, please pay attention to PHP Chinese website!

The above is the detailed content of ThinkPHP custom success and error jump pages. For more information, please follow other related articles on the PHP Chinese website!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to quickly set up a custom avatar in Netflix How to quickly set up a custom avatar in Netflix Feb 19, 2024 pm 06:33 PM

An avatar on Netflix is ​​a visual representation of your streaming identity. Users can go beyond the default avatar to express their personality. Continue reading this article to learn how to set a custom profile picture in the Netflix app. How to quickly set a custom avatar in Netflix In Netflix, there is no built-in feature to set a profile picture. However, you can do this by installing the Netflix extension on your browser. First, install a custom profile picture for the Netflix extension on your browser. You can buy it in the Chrome store. After installing the extension, open Netflix on your browser and log into your account. Navigate to your profile in the upper right corner and click

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

To run the ThinkPHP project, you need to: install Composer; use Composer to create the project; enter the project directory and execute php bin/console serve; visit http://localhost:8000 to view the welcome page.

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

ThinkPHP has multiple versions designed for different PHP versions. Major versions include 3.2, 5.0, 5.1, and 6.0, while minor versions are used to fix bugs and provide new features. The latest stable version is ThinkPHP 6.0.16. When choosing a version, consider the PHP version, feature requirements, and community support. It is recommended to use the latest stable version for best performance and support.

How to customize shortcut key settings in Eclipse How to customize shortcut key settings in Eclipse Jan 28, 2024 am 10:01 AM

How to customize shortcut key settings in Eclipse? As a developer, mastering shortcut keys is one of the keys to improving efficiency when coding in Eclipse. As a powerful integrated development environment, Eclipse not only provides many default shortcut keys, but also allows users to customize them according to their own preferences. This article will introduce how to customize shortcut key settings in Eclipse and give specific code examples. Open Eclipse First, open Eclipse and enter

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

The operation process of edius custom screen layout The operation process of edius custom screen layout Mar 27, 2024 pm 06:50 PM

1. The picture below is the default screen layout of edius. The default EDIUS window layout is a horizontal layout. Therefore, in a single-monitor environment, many windows overlap and the preview window is in single-window mode. 2. You can enable [Dual Window Mode] through the [View] menu bar to make the preview window display the playback window and recording window at the same time. 3. You can restore the default screen layout through [View menu bar>Window Layout>General]. In addition, you can also customize the layout that suits you and save it as a commonly used screen layout: drag the window to a layout that suits you, then click [View > Window Layout > Save Current Layout > New], and in the pop-up [Save Current Layout] Layout] enter the layout name in the small window and click OK

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Performance comparison of Laravel and ThinkPHP frameworks: ThinkPHP generally performs better than Laravel, focusing on optimization and caching. Laravel performs well, but for complex applications, ThinkPHP may be a better fit.

Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks Development suggestions: How to use the ThinkPHP framework to implement asynchronous tasks Nov 22, 2023 pm 12:01 PM

"Development Suggestions: How to Use the ThinkPHP Framework to Implement Asynchronous Tasks" With the rapid development of Internet technology, Web applications have increasingly higher requirements for handling a large number of concurrent requests and complex business logic. In order to improve system performance and user experience, developers often consider using asynchronous tasks to perform some time-consuming operations, such as sending emails, processing file uploads, generating reports, etc. In the field of PHP, the ThinkPHP framework, as a popular development framework, provides some convenient ways to implement asynchronous tasks.

See all articles