下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、CodeIgniter集成smarty的方法详解_ 本文实例讲解并描述了CodeIgniter集成smarty的方法。分享给大家供大家参考,具体步骤如下: 1.下载smarty 解压到ci的libraries名目 如: ci/application/libraries/Smarty-2.6.20 2.编写Mysmarty.php 自己的类库文件 代码如下: ?php if (!defined(BASEPATH) exit(No direct script access allowed); require Smarty-2.6.20/libs/Smarty.class.php; /* * fil
2、e system/application/libraries/Mysmarty.php */ class Mysmarty extends Smarty function Mysmarty() $this-Smarty(); $config = get_config(); / absolute path prevents template not found errors $this-template_dir = (!empty($configsmarty_template_dir) ? $configsmarty_template_dir : BASEPATH . application/v
3、iews/); $this-compile_dir = (!empty($configsmarty_compile_dir) ? $configsmarty_compile_dir : BASEPATH . cache/); /use CIs cache folder if (function_exists(site_url) / URL helper required $this-assign(site_url, site_url(); / so we can get the full path to CI easily /* * param $resource_name string *
4、param $params array holds params that will be passed to the template * desc loads the template */ function view($resource_name, $params = array() if (strpos($resource_name, .) = false) $resource_name .= .html; if (is_array($params) count($params) foreach ($params as $key = $value) $this-assign($key,
5、 $value); / check if the template file exists. if (!is_file($this-template_dir . $resource_name) show_error(template: $resource_name cannot be found.); return parent:display($resource_name); / END class smarty_library ? 3.在autoload.php让ci自动加载smarty $autoloadlibraries = array(database, mysmarty); 或者 用法模板时再自己加载smarty $this-load-library(mysmarty); 4.smarty变量赋值 display模板 $this-mysmarty-assign(test, Hello World.); $this-mysmarty-view(smarty); 注:images css 等外部资源文件 放在ci系统文件夹外 网站根名目下 最好用: $this-load-helper(url); ba
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026丽水市宏盛人力资源开发有限公司公开招聘派遣至丽水市中心医院员工7人考试参考题库及答案解析
- 2026年济南市历城区公务员人员招聘笔试备考题库与答案详解
- 2026年关于财政存量资金清理情况的自查报告
- 2026年工程质量安全总监考核试题及答案
- 2026年漯河市召陵区公务员人员招聘笔试参考试题与答案详解
- 2025十八项医疗核心制度考试题库及参考答案
- 2025年寨卡病毒考试试题及答案
- 2026年安全生产月安全生产知识竞赛题库及答案(精-品)
- 2025年地质调查员(地质灾害方向)职业技能竞赛试题及答案
- 2026福建莆田仙游度尾镇向社会公开招聘消防员2名考试备考试题及答案解析
- 一元二次方程应用说课课件
- 冬季预防抑郁2026知识培训
- 2026中国建筑工程勘察行业市场现状发展趋势分析投资评估规划分析研究报告
- 人防有限空间作业监理实施细则
- 三1班小学生竞选班委班干部竞选简历
- 肺功能测定临床应用及结果的解读
- 考三轮车三力测试题及答案
- 电机维修技术协议与服务标准范本
- 三年级上册语文课件《整本书阅读稻草人》-人教部编版
- 艺术教育公平性探索-洞察及研究
- 张掖介绍课件
评论
0/150
提交评论