Smarty笔记

来源:互联网 发布:合肥优化外包公司 编辑:程序博客网 时间:2024/05/21 17:46

首先是配置:

<?php
require 'libs/Smarty.class.php';
$smarty = new Smarty;

$smarty->template_dir = "templates";
$smarty->compile_dir = "templates_c";
$smarty->config_dir = "config";
$smarty->cache_dir = "cache";
$smarty ->left_delimiter = "<{";
$smarty ->right_delimiter = "}>";

$smarty->assign('title','用户注册页');
$smarty->display('index.html');

?>

其次是遇到的问题总结:

在用smaty模版开发的过程中,在templates中存放的都是模版面通常是以tpl和html格式的文件,所有的页面都是通过index,php控制的.路径也就是都相对于index.php文件.所以在加载images、css、js文件的时候一般写成

<link href=”templates/css/style.css” rel=”stylesheet” type=”text/css” />

但是需要注意的就是在模版页面引入外部css样式文件的时候路径 的关系就发生改变了,对于css来说的相对文件就是index.html模版文件了
如果在css文件加载图片的时候
就应该写成background-image: url(../templates/img/03.jpg);

 

(后续会跟着更新)

原创粉丝点击