View Single Post
Old 09-21-2007, 07:04 PM   #1 (permalink)
Haris
The Frequenter
Prolific Welcomer Upcoming Programmer 
 
Join Date: Sep 2007
Posts: 360
Thanks: 24
Haris is on a distinguished road
Default 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:
  1. Download the latest stable Smarty release http://smarty.php.net/download.php
  2. Create templates_c, templates and configs folder in your PHP project root directory
  3. Copy all the files and folders from the libs folder which came with Smarty package
  4. Paste the files and folders to the root directory of your PHP project where templates, templates_c and configs folder resides.
  5. 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. :)
Haris is offline  
Reply With Quote