Friday, January 23, 2009

SMARTY CONFIG

if no then read this :-
Smarty is known as a "Template Engine" . Smarty is described as a Presentation FrameWork.
In php business logic and Presentation code are save in same file (in .php)
there is nothing to separate the business logic and presentation part .
if in your application u want to change the only presentation of your application
so u need change both presentation and business logic that not require.
So using Smarty u can follow mvc archit. in php.
so guys learn it and implement in your application.
WebSite :- http://www.smarty.net/

Installing Smarty in Windows
Download Smarty - http://smarty.php.net
Installation - Windows, IIS/Apache, PHP5
Extract files, rename Smarty.x.x.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:
// 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/config';
$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

Hello, {$name}!

/html
Now open index.php in your web browser (requested from your webserver)

0 comments:

There was an error in this gadget