注意事项:
1、在当前子模板中,只能定义区块而不能定义其他的模板内容,否则将会直接忽略
Paste_Image.png
2、thinkphp3.2.3默认不支持标签嵌套
项目中一个使用实例
1、Public目录下
base.html
top.html
搜索感兴趣的内容
top.html文件里也有个block区块
nav.html
head.html 和 footer.html文件只是引入公共css、js文件
2、其他视图页面继承基础模版
Home/ContactController.class.php
namespace Home\Controller;
use Think\Controller;
class ContactController extends Controller {
public function index(){
$config = C('nav_info');
$current_nav_id = $config[9]['id'];
$banner_img = M('nav')->where(array('id'=>$current_nav_id))->getfield('pic');
$contact_info = M('contact')->find();
$this->assign(
array(
'nav_id' => $current_nav_id,//渲染当前页面的id
'banner_img' => $banner_img,
'contact_info' => $contact_info,
));
$this->display();
}
}
Home/View/Contact/index.html
![](__PUBLIC__/Home/images/contact-tit.png)
{$contact_info.contact_name}
{$contact_info.contact_content}