返回布局模板,模板......登陆

布局模板,模板继承

Jokey,2019-02-18 00:12:47280

eeeee.png


//控制器

<?php
namespace app\index\controller;
use think\Controller;
class Index extends Controller
{	
	  public function index()
    {
        //渲染视图
        return $this->fetch();
    }   

    public function add(){

        //渲染视图
        return $this->fetch();
    }
    
}

//模板部分

index.hml

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
	<title>无标题</title>
	<style type="text/css">
		.main{
			width: 800px;
			height: 600px;
			background: black;
			margin: auto;
			text-align: center;
			line-height: 600px;
			color: red;
		}

	</style>
</head>
<body>
		<div class="main">这个是index.html</div>
		
</body>
</html>

//add.html

{extend name="common"/}

{//重新父模板}

{block name="common"}
	<div style="text-align: center;"> 主体部分</div>
{/block}

//common.html

{//头部内容}
{block name="header"}
	{include file="public/header"}
{/block}

{block name="main"} 主体部分{/block}

{block name="footer"}
	{include file="public/footer"}
{/block}


//layout.html

{include file="public/header"}
{__CONTENT__}
{include file="public/footer"}


最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送