侧边栏最新评论按评论数最多输出文章标题,以下按默认板子为例:将模版module.php中的
<?php //widget:最新评论 function widget_newcomm($title){ global $CACHE; $com_cache = $CACHE->readCache('comment'); ?> <li> <h3><span><?php echo $title; ?></span></h3> <ul id="newcomment"> <?php foreach($com_cache as $value): $url = Url::comment($value['gid'], $value['page'], $value['cid']); ?> <li id="comment"><?php echo $value['name']; ?> <br /><a href="<?php echo $url; ?>"><?php echo $value['content']; ?></a></li> <?php endforeach; ?> </ul> </li> <?php }?>
替换成
<?php //widget:热评文章 function widget_newcomm($title){$index_comnum = Option::get('index_comnum');?> <li> <h3><span><?php echo $title;?></span></h3> <ul id="newcomment"> <?php $db = MySql::getInstance();$db = MySql::getInstance(); $sql = $db->query ("SELECT * FROM ".DB_PREFIX."blog inner join ".DB_PREFIX."sort WHERE hide='n' AND type='blog' AND top='n' AND sortid=sid order by `comnum` DESC limit 0,$index_comnum"); while($row = $db->fetch_array($sql)){?> <li id="comment"><a href="<?php echo Url::log($row['gid']);?>" title="<?php echo $row['title'];?>" /><?php echo $row['title'];?></a></li> <?php }?></ul><?php }?>
这样就搞定收工了!
觉得文章有用就打赏一下文章作者
微信扫一扫打赏