Skip to content

Instantly share code, notes, and snippets.

@nerdmom
Created December 28, 2009 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nerdmom/264823 to your computer and use it in GitHub Desktop.
Save nerdmom/264823 to your computer and use it in GitHub Desktop.
// Makes it extremely easy to integrate code igniter and smarty as well as provide layout capabilites
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
require "smarty/Smarty.class.php";
class Template extends Smarty{
var $theme = "default";
function __construct()
{
$this->tpl = new Smarty();
$this->tpl->template_dir = ROOTPATH . "templates/";
$this->tpl->compile_dir = APPPATH . "libraries/smarty/templates_c/";
$this->tpl->config_dir = APPPATH . "libraries/smarty/config/";
$this->tpl->plugins_dir = APPPATH . "libraries/smarty/plugins/";
}
function assign($key,$value)
{
$this->tpl->assign($key,$value);
}
function display($template)
{
$this->tpl->display($template);
}
function fetch($template)
{
$this->tpl->fetch($template);
}
function layout($inner_template,$array)
{
foreach($array as $key=>$val) {
$this->assign($key,$val);
}
$this->assign("inner_template",$inner_template);
$this->display($this->theme.".tpl");
exit;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment