thinkphp 模板写php,thinkphp 模版继承的使用

注意事项:

1、在当前子模板中,只能定义区块而不能定义其他的模板内容,否则将会直接忽略

321b1b24dae6

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}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值