Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4970334
  • 博文数量: 921
  • 博客积分: 16037
  • 博客等级: 上将
  • 技术积分: 8469
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-05 02:08
文章分类

全部博文(921)

文章存档

2020年(1)

2019年(3)

2018年(3)

2017年(6)

2016年(47)

2015年(72)

2014年(25)

2013年(72)

2012年(125)

2011年(182)

2010年(42)

2009年(14)

2008年(85)

2007年(89)

2006年(155)

分类:

2006-11-06 22:29:26

1、下载Smarty包
可以从官方站点下载:

2、解压缩Smarty包并找到合适的位置存放,文件夹名存为是Smarty。将含有Smarty文件的文件夹拷贝到某一个目录下。

下面内容中,我们都是假设你的文件放在了C:\Apache2\include\Smarty下。

3、找到你的php.ini配置文件修改php.ini的include_path选项,把smarty的库文件路径加上,比如:
include_path = "C:\Apache2\include\Smarty\libs"

提醒一下,php.ini中一共有两处include_path,一处是Unix下使用的,一处是windows下使用的,要修改windows下使用的:
-------------------------------------------------------------
; Windows: "\path1;\path2"
include_path = "C:\Apache2\include\Smarty\libs"

4、在你的网站目录下创建一个文件夹,名字任意,假设叫Smarty:
然后再在这个MySmarty目录下创建4个文件夹,templates、configs、template-c和cache。
创建完成之后如下:
(你的网站目录)/Smarty/templates (这个目录用来存放模版)
(你的网站目录)/Smarty/configs (这个目录用来存放一些配置信息)

(你的网站目录)/Smarty/templates-c (这个目录用来存放编译文件)

(你的网站目录)/Smarty/cache (这个目录用来存放缓存)

5、这时候你别忘了把我们上面从一开始到现在创建的四个文件夹的权限设置好。

,在“属性”中打开“安全”标签,在里面列出了可以访问这个目录的用户列表,

如果没有web访问权限,则需要添加,把Internet来宾帐户和启动IIS进程帐户两个帐户都添加上即可。如果觉得麻烦,可以直接将Everyone用

户组添加上,允许任何用户访问。
6、这时候安装工作基本完成,可以进行第一个简单例子的测试:
在你的网站目录下建立 index.php文件,并且在(网站目录)/smarty/templates/下建立index.tpl文件,分别输入以下代码
index.php
//载入Smarty库,如果在php.ini设置了include_path为C:\Apache2\include\Smarty\libs,那么可以直接用include("Smarty.class.php");
//另外不设置include_path,可以直接把Smarty.class.php拷到网站目录,就不用加绝对路径了。
require('C:\Apache2\include\Smarty\libs\Smarty.class.php');

$smarty = new Smarty;

//下面的(你的网站目录)用绝对路径,可以用相对路径(./templates)
$smarty->template_dir='C:\Apache2\htdocs\mysmarty\templates';
$smarty->config_dir='C:\Apache2\htdocs\mysmarty\configs';
$smarty->cache_dir='C:\Apache2\htdocs\mysmarty\cache';
$smarty->compile_dir='C:\Apache2\htdocs\mysmarty\templates_c';
//上面四行为使用Smarty前的必要参数配置

$smarty->assign('name','明天');
$smarty->display('index.tpl');
?>

index.tpl


你好,{$name}!



7、现在终于可以浏览自己的作品。运行index.php
阅读(2487) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~