#1 lvqing
按照 j大 的教程,配置文件中的模板部分'view' => array (
'enabled' => TRUE,
'config' =>array(
'template_dir' => APP_PATH.'/tpl',
),
'engine_name' => 'speedy', // 模板引擎的类名称
'engine_path' => SP_PATH.'/Drivers/speedy.php', // 模板引擎主类路径
),
控制器中
class main extends comController
{
function index ()
{
$this->errmsg = $this->spArgs ('errmsg');
$this->errmsg = urldecode ($this->errmsg);
$mod_work = spClass ("lib_work");
$this->rs_list = $mod_work->getPihaoList ();
var_dump ($this->rs_list);
//$this->display ("index/index.html");
$this->display ("index/index.php");
} // function index () {}
}
tpl/index
index.html
index.php
require (APP_PATH.'/tpl/share/top.php');
if ($errmsg != '') {
print_r ($errmsg);
print_r ('
');
}
print <<
批次、下载列表
EOT;
if ($rs_list) {
print <<
批次 | 下载 | |
'.$v['pihao'].' | '.PHP_EOL;'.$v['pihao'].'.xls | '.PHP_EOL;'.$v['pihao'].'未完成处理 | '.PHP_EOL;
}
else {
echo '
暂无
'.PHP_EOL;}
require (APP_PATH.'/tpl/share/footer.php');
?>
以上代码,能 dump 出来数据集内容,但是页面无显示。
请 j大 指导下 speedy 模板具体使用方法
1、模板文件 是 html 还是 php
2、一般模板都会分解为页头、内容、页脚几个部分,speedy 模板中调用其它的模板文件
直接用 require 是否对,类似
require (APP_PATH.'/tpl/share/top.php');
这样
3、如果在 print <<
后面的静态文本中要插入 php 代码片段,是否可能,如果可能,怎么写
比如循环输出数据集字段数据时
print <<
EOT;
这种写法是否对?
PS:放弃 smarty 用 speedy 的缘由:
一个简单的小程序,前台模板中需要直接调用 php 函数处理一些数据
以上,麻烦 j大。
2015-10-21 14:45:51