当前位置:网站首页>Use of ThinkPHP template
Use of ThinkPHP template
2022-07-05 17:11:00 【qq_ forty-two million three hundred and seven thousand five hun】
thinkphp The template file of is placed in /home/View The template file here needs to be consistent with the name of the controller
For example, in view Create a new one in the directory Index Directory so Index The controller will call the template file of this directory
newly build Index The directory is being created index.html The contents are as follows 
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title> Scorpio </title>
</head>
<body>
<p>helloworld</p>
</body>
</html>
rewrite IndexController.class.php Of index Method
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
$this->display();
}
?>
display Method is used to call the access of template file index.php/home/index/index You can access Index Under the table of contents index.html Templates
Can be in display Add parameters to specify the template file to be accessed
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index(){
$this->display();
}
public function test(){
$this->display("index");;
}
}
When we visit index.php/home/index/test In fact, what I visited was index.html Template because we are display It specifies
Template commonly used static variables
PUBLIC It stands for /Public This directory is used to store css js Style file
/home/view/Index/index.html
<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<title> Simple general article system background management template </title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/common.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__ /css/main.css"/>
</head>
<body>
<div class="topbar-wrap white">
<div class="topbar-inner clearfix">
<div class="topbar-logo-wrap clearfix">
<h1 class="topbar-logo none"><a href="index.html" class="navbar-brand"> Background management </a></h1>
<ul class="navbar-list clearfix">
<li><a class="on" href="index.html"> home page </a></li>
<li><a href="#" target="_blank"> homepage </a></li>
</ul>
</div>
<div class="top-info-wrap">
<ul class="top-info-list clearfix">
<li><a href="#"> Administrators </a></li>
<li><a href="#"> Change Password </a></li>
<li><a href="#"> sign out </a></li>
</ul>
</div>
</div>
</div>
<div class="container clearfix">
<div class="sidebar-wrap">
<div class="sidebar-title">
<h1> menu </h1>
</div>
<div class="sidebar-content">
<ul class="sidebar-list">
<li>
<a href="#"><i class="icon-font"></i> Common operations </a>
<ul class="sub-menu">
<li><a href="design.html"><i class="icon-font"></i> Work management </a></li>
<li><a href="design.html"><i class="icon-font"></i> Blog management </a></li>
<li><a href="design.html"><i class="icon-font"></i> Classification management </a></li>
<li><a href="design.html"><i class="icon-font"></i> message management </a></li>
<li><a href="design.html"><i class="icon-font"></i> Comment management </a></li>
<li><a href="design.html"><i class="icon-font"></i> link </a></li>
<li><a href="design.html"><i class="icon-font"></i> Advertising management </a></li>
</ul>
</li>
<li>
<a href="#"><i class="icon-font"></i> System management </a>
<ul class="sub-menu">
<li><a href="system.html"><i class="icon-font"></i> System settings </a></li>
<li><a href="system.html"><i class="icon-font"></i> Clean cache </a></li>
<li><a href="system.html"><i class="icon-font"></i> The data backup </a></li>
<li><a href="system.html"><i class="icon-font"></i> Data restore </a></li>
</ul>
</li>
</ul>
</div>
</div>
<!--/sidebar-->
<div class="main-wrap">
<div class="crumb-wrap">
<div class="crumb-list"><i class="icon-font"></i><span> Welcome to use 『 Passion 』 Blog program , The preferred tool for Jianbo .</span></div>
</div>
<div class="result-wrap">
<div class="result-title">
<h1> shortcuts </h1>
</div>
<div class="result-content">
<div class="short-wrap">
<a href="insert.html"><i class="icon-font"></i> New works </a>
<a href="insert.html"><i class="icon-font"></i> The new post </a>
<a href="insert.html"><i class="icon-font"></i> New work categories </a>
<a href="insert.html"><i class="icon-font"></i> New blog category </a>
<a href="#"><i class="icon-font"></i> Work review </a>
</div>
</div>
</div>
<div class="result-wrap">
<div class="result-title">
<h1> System basic information </h1>
</div>
<div class="result-content">
<ul class="sys-info-list">
<li>
<label class="res-lab"> operating system </label><span class="res-info">WINNT</span>
</li>
<li>
<label class="res-lab"> Running environment </label><span class="res-info">Apache/2.2.21 (Win64) PHP/5.3.10</span>
</li>
<li>
<label class="res-lab">PHP Operation mode </label><span class="res-info">apache2handler</span>
</li>
<li>
<label class="res-lab"> Design quietly - edition </label><span class="res-info">v-0.1</span>
</li>
<li>
<label class="res-lab"> Upload attachment restrictions </label><span class="res-info">2M</span>
</li>
<li>
<label class="res-lab"> Beijing time. </label><span class="res-info">2014 year 3 month 18 Japan 21:08:24</span>
</li>
<li>
<label class="res-lab"> Server domain name /IP</label><span class="res-info">localhost [ 127.0.0.1 ]</span>
</li>
<li>
<label class="res-lab">Host</label><span class="res-info">127.0.0.1</span>
</li>
</ul>
</div>
</div>
<div class="result-wrap">
<div class="result-title">
<h1> Use the help </h1>
</div>
<div class="result-content">
<ul class="sys-info-list">
<li>
<label class="res-lab"> More templates :</label><span class="res-info"><a href="http://www.codejie.net/" target="_blank"> Source street - Free source download </a></span>
</li>
</ul>
</div>
</div>
</div>
<!--/main-->
</div>
</body>
</html>
Create a header template in view Create under directory comm The directory is creating head.html
/home/view/comm/head.html
<!doctype html>
<html>
<head>
<meta charset="UTF-8"/>
<title> Background management </title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/common.css"/>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/css/main.css"/>
</head>
<body>
<div class="topbar-wrap white">
<div class="topbar-inner clearfix">
<div class="topbar-logo-wrap clearfix">
<h1 class="topbar-logo none"><a href="index.html" class="navbar-brand"> Background management </a></h1>
<ul class="navbar-list clearfix">
<li><a class="on" href="index.html"> home page </a></li>
<li><a href="#" target="_blank"> homepage </a></li>
</ul>
</div>
<div class="top-info-wrap">
<ul class="top-info-list clearfix">
<li><a href="#"> Administrators </a></li>
<li><a href="#"> Change Password </a></li>
<li><a href="#"> sign out </a></li>
</ul>
</div>
</div>
</div>
<div class="container clearfix">
<div class="sidebar-wrap">
<div class="sidebar-title">
<h1> menu </h1>
</div>
<div class="sidebar-content">
<ul class="sidebar-list">
<li>
<a href="#"><i class="icon-font"></i> Common operations </a>
<ul class="sub-menu">
<li><a href="design.html"><i class="icon-font"></i> Work management </a></li>
<li><a href="design.html"><i class="icon-font"></i> Blog management </a></li>
<li><a href="design.html"><i class="icon-font"></i> Classification management </a></li>
<li><a href="design.html"><i class="icon-font"></i> message management </a></li>
<li><a href="design.html"><i class="icon-font"></i> Comment management </a></li>
<li><a href="design.html"><i class="icon-font"></i> link </a></li>
<li><a href="design.html"><i class="icon-font"></i> Advertising management </a></li>
</ul>
</li>
<li>
<a href="#"><i class="icon-font"></i> System management </a>
<ul class="sub-menu">
<li><a href="system.html"><i class="icon-font"></i> System settings </a></li>
<li><a href="system.html"><i class="icon-font"></i> Clean cache </a></li>
<li><a href="system.html"><i class="icon-font"></i> The data backup </a></li>
<li><a href="system.html"><i class="icon-font"></i> Data restore </a></li>
</ul>
</li>
</ul>
</div>
</div>
stay /home/view/index.html This header template is directly included in
<include file="comm/head" />
<!--/sidebar-->
<div class="main-wrap">
<div class="crumb-wrap">
<div class="crumb-list"><i class="icon-font"></i><span> Welcome to use 『 Passion 』 Blog program , The preferred tool for Jianbo .</span></div>
</div>
<div class="result-wrap">
<div class="result-title">
<h1> shortcuts </h1>
</div>
<div class="result-content">
<div class="short-wrap">
<a href="insert.html"><i class="icon-font"></i> New works </a>
<a href="insert.html"><i class="icon-font"></i> The new post </a>
<a href="insert.html"><i class="icon-font"></i> New work categories </a>
<a href="insert.html"><i class="icon-font"></i> New blog category </a>
<a href="#"><i class="icon-font"></i> Work review </a>
</div>
</div>
</div>
<div class="result-wrap">
<div class="result-title">
<h1> System basic information </h1>
</div>
<div class="result-content">
<ul class="sys-info-list">
<li>
<label class="res-lab"> operating system </label><span class="res-info">WINNT</span>
</li>
<li>
<label class="res-lab"> Running environment </label><span class="res-info">Apache/2.2.21 (Win64) PHP/5.3.10</span>
</li>
<li>
<label class="res-lab">PHP Operation mode </label><span class="res-info">apache2handler</span>
</li>
<li>
<label class="res-lab"> Design quietly - edition </label><span class="res-info">v-0.1</span>
</li>
<li>
<label class="res-lab"> Upload attachment restrictions </label><span class="res-info">2M</span>
</li>
<li>
<label class="res-lab"> Beijing time. </label><span class="res-info">2014 year 3 month 18 Japan 21:08:24</span>
</li>
<li>
<label class="res-lab"> Server domain name /IP</label><span class="res-info">localhost [ 127.0.0.1 ]</span>
</li>
<li>
<label class="res-lab">Host</label><span class="res-info">127.0.0.1</span>
</li>
</ul>
</div>
</div>
<div class="result-wrap">
<div class="result-title">
<h1> Use the help </h1>
</div>
<div class="result-content">
<ul class="sys-info-list">
<li>
<label class="res-lab"> More templates :</label><span class="res-info"><a href="http://www.codejie.net/" target="_blank"> Source street - Free source download </a></span>
</li>
</ul>
</div>
</div>
</div>
<!--/main-->
</div>
</body>
</html>
/home/view/comm/insert.html
<include file="comm/head" />
<!--/sidebar-->
<div class="main-wrap">
<div class="crumb-wrap">
<div class="crumb-list"><i class="icon-font"></i><a href="/jscss/admin/design/"> home page </a><span class="crumb-step">></span><a class="crumb-name" href="/jscss/admin/design/"> Work management </a><span class="crumb-step">></span><span> New works </span></div>
</div>
<div class="result-wrap">
<div class="result-content">
<form action="/jscss/admin/design/add" method="post" id="myform" name="myform" enctype="multipart/form-data">
<table class="insert-tab" width="100%">
<tbody><tr>
<th width="120"><i class="require-red">*</i> classification :</th>
<td>
<select name="colId" id="catid" class="required">
<option value=""> Please select </option>
<option value="19"> Boutique interface </option><option value="20"> Recommendation interface </option>
</select>
</td>
</tr>
<tr>
<th><i class="require-red">*</i> title :</th>
<td>
<input class="common-text required" id="title" name="title" size="50" value="" type="text">
</td>
</tr>
<tr>
<th> author :</th>
<td><input class="common-text" name="author" size="50" value="admin" type="text"></td>
</tr>
<tr>
<th><i class="require-red">*</i> thumbnail :</th>
<td><input name="smallimg" id="" type="file"><!--<input type="submit" onclick="submitForm('/jscss/admin/design/upload')" value=" To upload pictures "/>--></td>
</tr>
<tr>
<th> Content :</th>
<td><textarea name="content" class="common-textarea" id="content" cols="30" style="width: 98%;" rows="10"></textarea></td>
</tr>
<tr>
<th></th>
<td>
<input class="btn btn-primary btn6 mr10" value=" Submit " type="submit">
<input class="btn btn6" onClick="history.go(-1)" value=" return " type="button">
</td>
</tr>
</tbody></table>
</form>
</div>
</div>
</div>
<!--/main-->
</div>
</body>
</html>
边栏推荐
- WSL2.0安装
- PHP talent recruitment system development source code recruitment website source code secondary development
- Use byte stream to read Chinese from file to console display
- Embedded-c Language-5
- 深耕5G,芯讯通持续推动5G应用百花齐放
- stirring! 2022 open atom global open source summit registration is hot!
- 调查显示传统数据安全工具面对勒索软件攻击的失败率高达 60%
- 【729. 我的日程安排表 I】
- 挖财股票开户安全吗?怎么开股票账户是安全?
- Judge whether a string is a full letter sentence
猜你喜欢
随机推荐
Embedded-c Language-2
拷贝方式之DMA
Thoughtworks 全球CTO:按需求构建架构,过度工程只会“劳民伤财”
通过proc接口调试内核代码
Keras crash Guide
叩富网开期货账户安全可靠吗?怎么分辨平台是否安全?
Solution of vant tabbar blocking content
How to write a full score project document | acquisition technology
挖财股票开户安全吗?怎么开股票账户是安全?
Embedded-c Language-1
CMake教程Step1(基本起点)
Learnopongl notes (II) - Lighting
American chips are no longer proud, and Chinese chips have successfully won the first place in emerging fields
【性能测试】jmeter+Grafana+influxdb部署实战
thinkphp3.2.3
Combined use of vant popup+ other components and pit avoidance Guide
基于51单片机的电子时钟设计
Deep dive kotlin synergy (XXI): flow life cycle function
【729. 我的日程安排表 I】
云安全日报220705:红帽PHP解释器发现执行任意代码漏洞,需要尽快升级









