搜索
系统检测到您的用户名不符合规范:

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

浏览:5000 发布日期: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>
请问怎么实现?十分感谢!
最佳答案
评论() 相关
收藏
vikinghetty
积分:1590 等级:LV3
热点推荐
(追記) (追記ここまで)
最新更新

我们

合作

网站

信息

ThinkPHP 是一个免费开源的,快速、简单的面向对象的 轻量级PHP开发框架 ,创立于2006年初,遵循Apache2开源协议发布,是为了敏捷WEB应用开发和简化企业应用开发而诞生的。ThinkPHP从诞生以来一直秉承简洁实用的设计原则,在保持出色的性能和至简的代码的同时,也注重易用性。并且拥有众多的原创功能和特性,在社区团队的积极参与下,在易用性、扩展性和性能方面不断优化和改进,已经成长为国内最领先和最具影响力的WEB应用开发框架,众多的典型案例确保可以稳定用于商业以及门户级的开发。

AltStyle によって変換されたページ (->オリジナル) /