Extended Setup

PHP Smarty

Smarty - the compiling PHP template engine
Prev 来源:PHP中文社区

Chapter 2. Installation
第二章.安装

Next

Extended Setup
扩展设置

// load Smarty library
require('Smarty.class.php');

// The setup.php file is a good place to load
// required application library files, and you
// can do that right here. An example:
// require('guestbook/guestbook.lib.php');是一个很好的加载应用程序的类库文件(就是扩展类)
//例如你可以在index文件里包含它

class Smarty_GuestBook extends Smarty {

 function Smarty_GuestBook() {
 
 		// Class Constructor. These automatically get set with each new instance.
 //类构造函数.创建实例的时候自动配置

		$this->Smarty();

		$this->template_dir = '/web/www.mydomain.com/smarty/guestbook/templates/';
		$this->compile_dir = '/web/www.mydomain.com/smarty/guestbook/templates_c/';
		$this->config_dir = '/web/www.mydomain.com/smarty/guestbook/configs/';
		$this->cache_dir = '/web/www.mydomain.com/smarty/guestbook/cache/'; 
		
		$this->caching = true;
		$this->assign('app_name','Guest Book');
 }

}
require('guestbook/setup.php');

$smarty = new Smarty_GuestBook;

$smarty->assign('name','Ned');

$smarty->display('index.tpl');

Prev 来源:PHP中文社区 Home Next
Basic Installation
基本安装
Up Smarty For Template Designers
模板设计者篇