|
楼主 |
发表于 2012-3-26 09:51:51
|
显示全部楼层
sdink 发表于 2012-3-26 09:23
贴你的lib出来
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
require_once('smarty/Smarty.class.php');
class My_Smarty extends Smarty
{
function __construct()
{
parent::__construct();
$tem_path = APPPATH.'views/';
$com_path = APPPATH.'cache/';
$this->template_dir = $tem_path; //模板目录
$this->compile_dir = $com_path; //编译目录
}
//加载指定模板并且同时加载默认加载模块
public function viewWithDefaultTemplate($model_path,$data_array = array())
{
//将数据传入到模板中去
foreach($data_array as $key => $value)
{
$this->assign($key,$value);
}
$this->display(HEADER_PATH); //加载头部模板
$this->display($model_path); //加载内容模板
$this->display(FOOTER_PATH); //加载尾部模板
}
}
?> |
|