我创建LastWidget.class.php
<?php
class LastWidget extends Widget {
public function render($data) {
$data['last']=M('News')->order('createtime desc')->limit(5)->select();
return $this->renderFile('',$data);
}
然后建立last.html
主要代码
<volist name="last" id="v">
<li><span>{$i}</span><a href="#">{$v[q_ti
</volist>
然后在要输出的模板上面例如一个body.html中
{:W('Hot')}
,但是往往看一些资料都有传参,因为说widget的意义在于在页面根据需要输出不同的内容 ,所以怎样传参才能实现啊,例如一个页面只想要输出“xiaoming”发表的消息,一个页面只想要输出“daxiong”发表的消息,设置字段u_id,我这个应该怎么改啊?
}
?>
最佳答案