2011-08-17 4 views

답변

1

글쎄, 며칠 전 똑똑한 시스템을 통합하기위한 단계였습니다.

  1. 다운로드 스마티에서 http://www.smarty.net/download
  2. 응용 프로그램 내부의 유식 폴더/THIRD_PARTY
  3. 응용 프로그램/라이브러리 smarty.php 파일을 만들고이

    require_once(APPPATH.'third_party/Smarty/libs/Smarty.class.php'); 
    
    class CI_Smarty extends Smarty { 
    
    protected $CI; 
    private $module; 
    
    public function __construct() 
    { 
        parent::__construct(); 
    
        // get CI istance 
        $this->CI =& get_instance(); 
        // fetch the calling module, need to check for views inside it 
        $this->module = $this->CI->router->fetch_module(); 
    
        // path 
        $this->setCompileDir(APPPATH . "cache/smarty/compiled"); 
        $this->setCacheDir(APPPATH . "cache/smarty/cached"); 
        $this->setTemplateDir(APPPATH . "views/templates"); 
    
        // to use $this inside our views/template 
        $this->assignByRef('this', $this->CI); 
    
        log_message('debug', "Smarty Class Initialized"); 
    } 
    
    public function display ($template, $cache_id = null, $compile_id = null, $parent = null) { 
        // automatically add .tpl extension if there is not in $template 
        if (strpos($template,'.') === FALSE) { 
         $template .= '.tpl'; 
        } 
        if (!empty($this->module)){ 
         $template = APPPATH . 'modules/' . $this->module . '/views/' . $template; 
        } 
        // call the original smarty function 
        parent::display($template, $cache_id, $compile_id, $parent); 
    } 
    } 
    
    /* End of file Smarty.php */ 
    /* Location: ./application/libraries/Smarty.php */ 
    

PS를 붙여 넣습니다 : 미안 들여 쓰기 용

이제 smarty를 $ this-> load-> library ('smarty')와 함께 사용하거나 자동으로로드하여 구성 파일에 $ autoload를 추가하십시오.

희망이 도움이됩니다.^

관련 문제