Smarty PHP Template Engine
/ ( ):
https://www.smarty.net/
, , , php , , , , ! !
business logic - presentation . , smarty , , ǿ
smarty
template engine php. , application logic presentation . .
PHP
:
( html ....)
<--- --->
:
, , , .
, html template tags .
. , .
:
, :
1:
www.smarty.net.
2: smarty , ,
:
/yourSiteFolder/smarty/
Config_File.class.php
debug.tpl
internals/
plugins/
Smarty.class.php
Smarty_Compiler.class.php
3: 4 ,
templates,templates_c,cache,configs , -
templates , compiled templates ,cached templates , config
4: index.php :
:
<?php
// put path to Smarty.class.php
require(./smarty/Smarty.class.php);
$smarty = new Smarty();
$smarty->template_dir = ./smarty/templates;
$smarty->compile_dir = ./smarty/templates_c;
$smarty->cache_dir = ./smarty/cache;
$smarty->config_dir = ./smarty/configs;
$smarty->assign(name, :I am Light Tiger, nice to meet you );
$smarty->display(index.tpl);
?>
5: index.tpl templates :
/yourSiteFolder/smarty/templates/index.tpl
:
:
<html>
<head>
<title>Smarty</title>
</head>
<body>
Hello, {$name}!
</body>
</html>
6: ,
http://localhost/yourSiteFolder/index.php
Hello, :I am Light Tiger, nice to meet you!
.
.
.
:
{$smaryVariable} php , {}
:
:
$smarty->assign(variableName,value);
( ):
:
$smarty->display(templateName.tpl);
:
{*this is a smarty comment that will not be displayed on the final output of the template*}
.
Smarty Date and Time zone