程序:
<?php
class NavWidget extends Widget{public function render($data){
$node=M('News','cn_');//这里是数据库表的实例化
$data["a"]=$node->where('flags=1 and channelid=145')->limit(8)->select();
$data['list']=$data["a"];
$data["b"]=$node->where('flags=1 and channelid=146')->limit(8)->select();
$data['listb']=$data["b"];
$content = $this->renderFile ('Nav', $data);
//dump($data);
//exit;
return $content;
}
}
?>
前台调用:
<volist name="list" id="L" >
<dd><a href="{:U('Chinese/News/news_detail',array('id'=>$L['id']))}">{$L.title|msubstr=0,8}...</a></dd>
</volist>
<dt>行业新闻</dt>
<!------标题读取---- -->
<volist name="listb" id="L">
<dd> <a href="{:U('Chinese/News/news_detail',array('id'=>$L['id']))}">{$L.title|msubstr=0,8}...</a> </dd>
</volist>