ThinkPHP如何跨模块调用Common公共模块的模板(含数据输出)

浏览:4990 发布日期:2016/01/23 分类:求助交流 关键字: Common 模板
【描述】

1、实现目标

使User模块调用Common公共模块的模板header.html(注意,header.html模板中有数据输出)

2、目录结构|--Application
  |--Common
   |--View
    |--default
     |--header.html
  |--User
   |--View
    |--default
     |--main.html
3、Common模块的Controller已经对header.html进行数据输出

[文件:Application/Common/Controller/IndexController.class.php]<?php
namespace Common\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function header(){
        $name = '小明';
        $this->assign('name',$name);
        $this->display();
    }
}
[文件:Application/Common/View/header.html]<html>
<body>
姓名:{$name}
</body>
</html>
【问题】

User模块的main.html如何才能调用header.html(包括其输出的数据)

[文件:Application/User/View/main.html]<html>
<body>
<!-- 调用header.html:表达式调不出来 -->
<include file="Common/default/Index/header" />
<!-- 调用header.html:绝对路径可以调出来,但数据不显示 -->
<include file="./Application/Common/View/default/header.html" />
<p>...其它内容...</p>
</body>
</html>
请问怎么实现?十分感谢!
最佳答案
评论( 相关
后面还有条评论,点击查看>>