main.php文件如下
<?php
require ('./comm/smarty.class.php');
define ('_SITE_ROOT','E:/smarty');
$tp1=new smarty();
$tp1->template_dir=_SITE_ROOT.'/templates/';
$tp1->template_c=_SITE_ROOT.'/templates_c/';
$tp1->config_dir=_SITE_ROOT.'/configs/';
$tp1->cache_dir=_SITE_ROOT.'/cache/';
$tp1->left_delimiter='{';
$tp1->right_delimiter='}';
?>test.php文件如下
<?php
require ('main.php');
global $tp1;
$tp1->assign('title','测试用的网页');
$tp1->assign('content','测试用的网页内容');
$tp1->display('test1.html');
?>
test1.html如下显示
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
{$title}
<br>
{$content}
</BODY>
</HTML>
<?php
require ('./comm/smarty.class.php');
define ('_SITE_ROOT','E:/smarty');
$tp1=new smarty();
$tp1->template_dir=_SITE_ROOT.'/templates/';
$tp1->template_c=_SITE_ROOT.'/templates_c/';
$tp1->config_dir=_SITE_ROOT.'/configs/';
$tp1->cache_dir=_SITE_ROOT.'/cache/';
$tp1->left_delimiter='{';
$tp1->right_delimiter='}';
?>test.php文件如下
<?php
require ('main.php');
global $tp1;
$tp1->assign('title','测试用的网页');
$tp1->assign('content','测试用的网页内容');
$tp1->display('test1.html');
?>
test1.html如下显示
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</HEAD>
<BODY>
{$title}
<br>
{$content}
</BODY>
</HTML>
你在调试的时候可以看到啊,只是在dw里看不到图片
smarty本来只是方便了程序员,而对美工来说变麻烦了点(如果美工懂smarty就好多了)
目录结构:smarty
|_libs
|_demo
|_images
|_configs
|_templates
| |_test.htm
|_images ///把images 再copy个到这里
|_templates_c
|_test.phpdw 中 css,图片 都 用相对路径 ./images/.....就可以了..
完成后在 del 就ok 了
改成:
<img src="images/smarty_icon.gif" width="88" height="31">PHP文件和模板结合,以PHP文件的路径为准!所以写模板里的链接,要以PHP文件的位置给出相对路径。
按照上面的方法。