PHP Classes

smarty manager class

Recommend this page to a friend!

      PHP Controller  >  All threads  >  smarty manager class  >  (Un) Subscribe thread alerts  
Subject:smarty manager class
Summary:smarty manager class
Messages:1
Author:ollecram
Date:2005-11-27 20:22:48
 

  1. smarty manager class   Reply   Report abuse  
Picture of ollecram ollecram - 2005-11-27 20:22:48
Looking the documentation I saw you pointed the need for a smarty class manager.
Here is one I found some time ago and could be useful.

<?php
//include some_kind_of_config.php
/*********Something like this**************
@define("SITE_ROOT",dirname(dirname(__FILE__)));
@define("SMARTY_DIR",SITE_ROOT."/libs/smarty/");
@define("TEMPLATE_DIR",SITE_ROOT."/templates");
@define("COMPILE_DIR",SITE_ROOT."/templates_c");
@define("CONFIG_DIR",SITE_ROOT."/configs");


if((substr(strtoupper(PHP_OS),0,3))=="WIN"){
if(!defined("PATH_SEPARATOR")){
define("PATH_SEPARATOR",";");
}
}else{
if(!defined("PATH_SEPARATOR")){
define("PATH_SEPARATOR",":");
}
}
********************************************/
require_once SMARTY_DIR.'Smarty.class.php';

class Page extends Smarty
{
//Override Smarty's default configs
function Page()
{
$this->Smarty();
// All these constants should be defined in the included config.php
$this->template_dir = TEMPLATE_DIR;
$this->compile_dir = COMPILE_DIR;
$this->config_dir = CONFIG_DIR;
$this->cache_dir = SMARTY_DIR . "cache/" ;
// This should popup smarty debug
$this->debugging = 1;
// Built-in plugins-dir
$this->plugins_dir[0] = SMARTY_DIR . 'plugins';
// Custom plugins
$this->plugins_dir[1] = SITE_ROOT . "/smarty_plugins";
}
}
/*****************Usage**********************************
$Page = new Page();
$content='Some content';
$Page->assign('content',$content);
$Page->display('index.tpl');
**********************************************************/
?>