Deploy background static page templates and background login pages in the actual combat part
Preface
The backend of the website is generally developed on the basic static page, and the static page is inserted into the dynamic data. First, we first find a backend website template. Here I use it layuiAdmin 后台管理模板
. Click to enter the official website . This framework is charged. Please purchase genuine commercials.
1. Deploy static resources to the project
1. Create a new background static resource folder
In the public/static
directory new admin
folder, layuiAdmin
the dist
copied files in the directory come:
go to home early adopters:http://tp6.com/static/admin/views/index.html
Two, background login page
1. Directory structure
Login controller:
<?php
namespace app\admin\controller;
use app\BaseController;
use think\facade\View;
class Login extends BaseController
{
public function index(){
return View::fetch('index');
}
}
2. Template string replacement configuration
Modify the config
files under the view.php
folder and add string replacement configuration:
'tpl_replace_string' => [
'{__STATIC__}' => '/static/'
],
The above configuration means that 模板引擎
it will be {__STATIC__}
replaced in the middle. /static/
The function of using template string replacement is mainly for the convenience of maintenance. It is convenient to configure the path of all static files at one time, ../
instead of worrying about how many to write . Copy the content of login.html to the template login page:
The original login page references the static file path:
<link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" href="../../layuiadmin/style/login.css" media="all">
change into:
<link rel="stylesheet" href="{__STATIC__}/admin/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="{__STATIC__}/admin/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" href="{__STATIC__}/admin/layuiadmin/style/login.css" media="all">
If a template
报驱动错误Driver [Think] not supported.
is used for access , the reason is thattp6
onlyPHP
native templates are supported by default , but the configuration fileconfig/view.php
configuration uses itThink
.
Solution:
- Use tp template for think-view installation
composer require topthink/think-view
- Use native template
to a profileconfig/view.php
in the'type' => 'Think'
revised to'type' => 'php'
- Use native templates
return View::engine('php')->fetch(“index”);
Login page access:http://tp6.com/admin/login/index