From: http://www.smarty.net/quick_start.php => http://news.php.net/php.smarty.dev/2703
This document assumes that your webserver and PhP5 is running.
Download smarty-http://smarty.php.net
Installation-Windows, IIS/Apache, PhP5
Extract files, rename smarty. x to smarty (suggest outside of your www root !)
Example: D: \ smarty
Run phpinfo. php to find out your php. ini location
Edit PHP. ini's include_path and add the location of the libs folder.
Example: include_path = ".; D: \ smarty \ Libs"
Restart IIS/Apache
Setup these two folders inside your www root:
(Wwwroot)/smarty/templates (this is where your templates will go)
(Wwwroot)/smarty/configs
Setup these two folders outside of your www root:
D:/smarty/templates_c
D:/smarty/Cache
Setup security settings for the webserver to write to these four folders
In (wwwroot) Create index. php and in (wwwroot)/smarty/templates/index. TPL with the following code:
Index. php:
<? PHP
// Load smarty Library
Require ('smarty. Class. php ');
$ Smarty = new smarty;
$ Smarty-> template_dir = 'd:/inetpub/wwwroot/smarty/templates ';
$ Smarty-> config_dir = 'd:/inetpub/wwwroot/smarty/configs ';
$ Smarty-> cache_dir = 'd:/smarty/smarty_cache ';
$ Smarty-> compile_dir = 'd:/smarty/smarty_templates_c ';
$ Smarty-> assign ('name', 'fish boy! ');
$ Smarty-> display ('index. TPL ');
?>
Index. TPL
<HTML>
<Body>
Hello, {$ name }!
</Body>
</Html>
Now open index. php In your web browser (requested from your webserver)
Http: // webserver/index. php
You can work this out to a referenced script/class:
Smarty_connect.php:
<? PHP
// Load smarty Library
Require ('smarty. Class. php ');
Class smarty_connect extends smarty
{
Function smarty_connect ()
{
// Class constructor.
// These automatically get set with each new instance.
$ This-> smarty ();
$ This-> template_dir = 'd:/inetpub/wwwroot/smarty/templates ';
$ This-> config_dir = 'd:/inetpub/wwwroot/smarty/config ';
$ This-> compile_dir = 'd:/smarty/templates_c ';
$ This-> cache_dir = 'd:/smarty/cache ';
$ This-> assign ('app _ name', 'intranet ');
}
}
?>
Index. php:
<? PHP
Require ('smarty _ connect. php ');
$ Smarty = new smarty_connect;
$ Smarty-> assign ('name', 'ned ');
$ Smarty-> display ('index. TPL ');
?>
Index. TPL:
<HTML>
<Body>
Hello, {$ name }!
</Body>
</Html>
If you are getting an error that smarty. class. PHP isn't found chances are that your include_path isn't correct or you didn't edit the one that the webserver is using, check your phpinfo. PHP!