国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

CI整合Smarty

2019-11-14 14:42:58
字體:
來源:轉載
供稿:網友

1.到相應的站點下載smarty模板

2.將源代碼中的libs目錄復制到項目的libraries目錄下,改名為smarty3.0

3.在項目目錄的libraries文件夾內新建文件ci_smarty.php,里面的內容如下:

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
require_once(APPPATH . 'libraries/smarty3.0/Smarty.class.php');
class ci_smarty extends Smarty
{
    PRotected $ci;
    public function  __construct(){
        $this->ci = & get_instance();
        $this->ci->load->config('smarty');//加載smarty的配置文件
        //獲取相關的配置項
        $this->template_dir   = $this->ci->config->item('template_dir');
        $this->complie_dir    = $this->ci->config->item('compile_dir');
        $this->cache_dir      = $this->ci->config->item('cache_dir');
        $this->config_dir     = $this->ci->config->item('config_dir');
        $this->template_ext   = $this->ci->config->item('template_ext');
        $this->caching        = $this->ci->config->item('caching');
        $this->cache_lifetime = $this->ci->config->item('lefttime');
    }
}

4.在項目目錄的config文件夾內新建文件smarty.php文件,里面的內容如下:

5.在入口文件所在目錄新建文件夾templates_c

6.在項目的配置文件夾下,autoload.php文件中加入

$autoload['libraries'] = array('ci_smarty');

7.在項目目錄的core文件夾中新建文件MY_Controller.php 內容如下: // 擴展核心控制類

8.測試

控制器中

視圖中


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嫩江县| 长治县| 抚松县| 梨树县| 枞阳县| 麦盖提县| 自治县| 府谷县| 恩平市| 吉林省| 大足县| 城口县| 郧西县| 中方县| 什邡市| 靖西县| 大同市| 阿坝县| 蓬莱市| 通辽市| 佛坪县| 汝州市| 平凉市| 益阳市| 西城区| 邓州市| 新泰市| 台安县| 钟祥市| 承德县| 南城县| 阿尔山市| 石景山区| 通州区| 洛阳市| 喀喇| 凤台县| 施甸县| 泾源县| 新巴尔虎右旗| 东辽县|