Google

Saturday, August 30, 2008

PHP with smarty template engine installation

PHP with smarty installation is so easy....

just download the stable version of smarty package and unzip the folder and rename folder name "smarty"

and now you create four directory in your application folder

1) config
2) templates_c
3) templates
4) cache

and just create one php file and here just specify the pathe of smaty.connect.php file and all four directory path

like the pls see example below

// put full path to Smarty.class.php
require('/usr/local/lib/php/Smarty/Smarty.class.php');
$smarty = new Smarty();

$smarty->template_dir = '/web/www.domain.com/smarty/templates';
$smarty->compile_dir = '/web/www.domain.com/smarty/templates_c';
$smarty->cache_dir = '/web/www.domain.com/smarty/cache';
$smarty->config_dir = '/web/www.domain.com/smarty/configs';

$smarty->assign('name', 'MANISH');
$smarty->display('index.tpl');

now include above php file anywhere and use the smartyy template magic.

any question then pls cooment here....i will give u the answer...thanks