`
aaron_ch
  • 浏览: 172493 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

PHP5.2 Smarty2.6.18 Coherent

    博客分类:
  • PHP
阅读更多

In my comany project,due to no time to manage the web structure(php), only leave the pure php files and other scripts in my project.from now on,under the cerntain situation, and with the project on-going and extension,need apply some new style to reorganize the project, The first step is: separate the display and logics. then I select the smarty template as the cutting-point. what's more,I put down the configure.
1.Download Smarty package  http://smarty.php.net/
2.Create a directory in web root such as app,then copy the libs folder under the smarty package to app folder.(my web root :C:/work/wwwroot)
3.Modify the php.ini for supporting the smarty template. add this in the php.ini:include_path=".;C:\Work\wwwroot\app\libs"
4.create templates,templates_c,configs,cache folders in the app directory.
5.write down index.php file in the app directory :
<?php
// load Smarty library
require('libs/Smarty.class.php');$smarty = new Smarty;$smarty->template_dir = 'templates';
$smarty->config_dir = 'config';
$smarty->compile_dir = 'templates_c';
$smarty->cache_dir = 'cache';
$smarty->assign('name','fish boy!');
$smarty->display('index.tpl');
?>
6.create a template file(index.tpl) in the templates folder:
<html>
<body>
Hello, {$name}!
</body>
</html>

Basically the directory structure is:
  wwwroot
              +app
                      +libs(files from smarty libs folder)
                      +templates(put the tpl file in this directory)
                      templates_c
                      configs
                      cache


7.run this http://localhost/app

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics