将以下代码放到module.php里,
//首页分类列表
function get_list($sort,$num){
$db = MySql::getInstance();
$sql = "SELECT gid,title,date FROM ".DB_PREFIX."blog WHERE sortid=".$sort." AND hide='n' ORDER BY `date` DESC LIMIT
0,".$num."";
$list = $db->query($sql);
while($row = $db->fetch_array($list)){
$l .= '<a href="'.Url::log($row['gid']).'">
<div class="baoliao_content">
<div class="bl_right">
<div class="bl_title">'.$row['title'].'</div>
</div>
</div>
</a>';
}
$sql = "SELECT sortname FROM ".DB_PREFIX."sort WHERE sid=".$sort;
$s = $db->query($sql);
$sortname = $db->fetch_array($s);
echo '<div class="m_baoliao w">
<div class="baoliao_title"><span>'.$sortname['sortname'].'</span><em><a href="'.Url::sort($sort).'">更多..</a></em></div>
<div class="baoliao_list">'.$l.'</div>
<div class="bl_more"><a href="'.Url::sort($sort).'">查看更多</a></div>
</div>';
}
然后在模板目录下log_list.php文件里使用<?php get_list(1,30);?>即可调用指定栏目文章列表,1表示分类id,30表示显示的数量
最新评论