代码 application\index\controller\index.php
<?php namespace app\index\controller; use app\index\controller; class Index extends IndexBase { public function index() { return $this->fetch(); } public function base () { return $this->fetch(); } }
模板application\index\view\index\index.html
{extend name="index/base" /} {block name="title"} Title: {/block} {block name="right"} 最新资讯: {/block} {block name="footer"} {__block__}@ThinkPHP 版权所有 {/block}
模板application\index\view\index\base.html
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>{block name="title"}标题{/block}</title> </head> <body> {block name="menu"}菜单{/block} {block name="left"}左边分栏{/block} {block name="main"}主内容{/block} {block name="right"}右边分栏{/block} {block name="footer"}底部{/block} </body> </html>
输出结果:菜单 左边分栏 主内容 最新资讯: 底部@ThinkPHP 版权所有
注意:{__block__}