zoukankan      html  css  js  c++  java
  • CI框架配置smarty

    新建一个libraries 代码如下:

    使用

    $this->ci_smarty->set('pv',$pv);
    $this->ci_smarty->set('pv_se',$pv_se);
    $this->ci_smarty->build('home.html');
    

    <?php
    // load Smarty library
    require_once(APPPATH.'libraries/smarty/Smarty.class.php');
    
    class CI_smarty extends Smarty {
    	private $viewData = array();
    
    	function __construct() {
    		parent :: __construct();
    		$this -> template_dir = APPPATH . 'views/';
    		$this -> compile_dir = APPPATH . 'cache/compile/';
    		$this -> config_dir = APPPATH . 'config';
    		$this -> cache_dir = APPPATH . 'cache/';
    		$this -> left_delimiter = '<%';
    		$this -> right_delimiter = '%>'; 
    		$this->caching = true;
    		//$this->testInstall();
    		@$this -> clear_all_cache(); 
    		//  $this->config_load('site.conf');
    		parse_str($_SERVER['QUERY_STRING'],$_GET);
    		$_GET = array_map('urldecode', $_GET);
    		if (isset($_GET["_d"]) && $_GET["_d"] == 1) {
    			$this -> debugging = true;
    		}
    	}
    
    	function set($key, $val) {
    		$arr = array();
    		$arr[$key] = $val;
    		if ($this->viewData) {
    			$this->viewData = array_merge($this->viewData,$arr);
    		} else {
    			$this->viewData = $arr;
    		}
    		//$this->assign('v', $this->viewData);
    	}
    
    	function build($template)
    	{
    		$this->assign('v', $this->viewData);
    		$this->display($template);
    	}
    }
    ?>
    

  • 相关阅读:
    Task async await
    信号量
    操作符?? 与 ?.
    Expression表单式树
    delegate Func Action Expression
    常用技术
    一次移动记账 App 的设计探索
    网站渗透测试教程--渗透测试基本程序
    【】网站渗透测试教程--了解渗透测试
    15 位健在的牛叉程序员,你知道哪几位?
  • 原文地址:https://www.cnblogs.com/greengnn/p/2004171.html
Copyright © 2011-2022 走看看