09-21-2007, 07:04 PM
|
#1 (permalink)
|
|
The Frequenter
Join Date: Sep 2007
Posts: 360
Thanks: 24
|
How to install smarty
Smarty is a known template engine. It has expanded library of functions to help you remove your template from the code .
To use Smarty as a standalone tool and avoid installing it server-side. Follow the steps below:
- Download the latest stable Smarty release http://smarty.php.net/download.php
- Create templates_c, templates and configs folder in your PHP project root directory
- Copy all the files and folders from the libs folder which came with Smarty package
- Paste the files and folders to the root directory of your PHP project where templates, templates_c and configs folder resides.
- Voila, you're done!
Now to test if Smarty is working.
First, create index.php and save it with the code below:
PHP Code:
<?php
// load Smarty library
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('name','fish boy!');
$smarty->display('index.tpl');
?>
Then, create index.tpl in the templates folder:
HTML Code:
<html>
<body>
Hello, {$name}!
</body>
</html>
If it renders Hello fish boy then Smarty is successfully connected. :)
|
|
|
|