#1 spitcold
以上我们初步了解了sp框架应用Smarty模板技术的方法以及模板的基础写法,下面我们在代码上面修改一下,让程序变得更有趣。
main.php
class main extends spController
{
function index(){ // 这里是首页
$tpl = $this->spArgs("tpl", "green"); // 这里接收tpl参数,使得模板变化,后面的green是tpl为空时的默认值。
$guestbook = spClass("guestbook");
$this->results = $guestbook->findAll();
$this->display("{$tpl}/index.html"); //问题:此行的$tpl旁边为什么要加{}
}
function write(){ // 这里是留言
$guestbook = spClass("guestbook");
$newrow = array( // 这里制作新增记录的值
'name' => $this->spArgs('name'),
'title' => $this->spArgs('title'), // 从spArgs获取到表单提交上来的title
2012-02-29 22:45:07