dome6实例
namespace app\index\controller;
// use think\View;
// use think\facade\View;
use think\Controller;
class Dome6 extends Controller
{
function index()
{
return '你好';
}
// 模板布局
/医院
* 1.全局配置:config/template
* 'layout_on' => true,
* 'layout_name' => 'layout',
*
* 2.模板标签配置
* ①不依赖全局直接使用标签配置
* ②{layout name='布局名字'}
*
* 3.动态配置
* ①不要在模板配置文件中进行任何配置
* ②也不要添加任何标签
*/
function index4()
{
//开启布局
// $this->view->engine->layout(true);
// $this->view->engine->layout('layout','{__TXT__}');
// return $this->fetch(); //index4
// 合并上边的两句
return $this->view
->engine
->layout(true)
->fetch('Dome6/index4');
}
//模板继承
function index5()
{
// view下base
//使用block __block__可以使用模板内容
return $this->fetch();
}
}
运行实例 »
点击 "运行实例" 按钮查看在线实例
index4.html{//__NOLAYOUT__}
{//layout name='layout'}
index5.html{extend name="base" /}
{block name="main"}
你好
{/block}layout.html{include file='template/header'}
{__CONTENT__}
{//__TXT__}
{include file='template/footer'}
base.html{block name="header" } {include file='template/header' /}{/block}
{block name="main"} {/block}
{block name="footer"} {include file='template/footer' /}{/block}
header.html
.div{
width: 80%;
height: 50px;
margin: auto;
background: #776693;
}
footer.html