[eluser]Alexander84[/eluser]
Frankly saying, I think your Smarty adapter is overbloated.
Here is a light-weight approach step-by-step.
1. Unpack latest Smarty to application/third_party/
2. Drop Mysmarty.php to application/libraries/
3 (optional, for beginners). Drop example.php to application/controllers/
4 (optional, for beginners). Drop example.tpl to application/views/
application/libraries/Mysmarty.php
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
define('SMARTY_DIR', APPPATH.'third_party/Smarty/');
require_once(SMARTY_DIR.'Smarty.class.php');
class Mysmarty extends Smarty
{
public function __construct ( )
{
parent::__construct();
$config =& get_config( );
$this->template_dir = APPPATH . 'views/';
$this->compile_dir = APPPATH . 'cache/smarty/compiled/';
$this->cache_dir = APPPATH . 'cache/smarty/cached/';
$this->caching = 2;
}
function view($resource_name, $params = array()) {
if (strpos($resource_name, '.') === false) {
$resource_name .= '.tpl';
}
if (is_array($params) && count($params)) {
foreach ($params as $key => $value) {
$this->assign($key, $value);
}
}
if (!is_file($this->template_dir . $resource_name)) {
show_error("template: [$resource_name] cannot be found.");
}
return parent::display($resource_name);
}
}
application/controllers/example.php
Code:
<?php
class Example extends CI_Controller {
function index()
{
$this->mysmarty->view('example');
}
}
application/controllers/example.tpl
Code:
<!DOCTYPE html>
<html>
<head>
<title>Example application - Current time</title>
</head>
<body>
<p>
— What time is it?<br />
— It's {$smarty.now|date_format:'%H:%M'} now!<br />
— Thank you, Sir.
</p>
</body>
</html>
That's all.