EMLOG按天数时间调用热门文章列表与随机文章列表

2023-05-11 11:04:15 浏览数 (1)

最近想改fee模板的随机文章和热门文章,不想要系统默认的感觉没有什么B格

让就是网上找的些代码在自己修改  以下是例子

代码语言:javascript复制
<?php
//30天按点击率排行文章
function getdatelogs($log_num) {
$db = MySql::getInstance();
$time = time();
$sql = "SELECT gid,title,comnum FROM ".DB_PREFIX."blog WHERE type='blog' AND date > $time - 30*24*60*60 ORDER BY `views` DESC LIMIT 0,$log_num";
$list = $db->query($sql);
while($row = $db->fetch_array($list)){ ?>
<li class="layout_li"><strong>[评论 <?php echo $row['comnum']; ?>]</strong><a href="<?php echo Url::log($row['gid']); ?>" title="<?php echo $row['title']; ?>"><span>热</span><?php echo $row['title']; ?></a></li>
<?php } ?>
<?php } ?>
<?php
//随机文章
function getRandLog($log_num) {
$db = MySql::getInstance();
$sql = "SELECT gid,title,comnum FROM ".DB_PREFIX."blog WHERE type='blog' and hide='n' ORDER BY rand() LIMIT 0,$log_num";
$list = $db->query($sql);
while($row = $db->fetch_array($list)){ ?>
<li class="layout_li"><strong>[<?php echo gettime($row['gid']);?>]</strong><a href="<?php echo Url::log($row['gid']); ?>" title="<?php echo $row['title']; ?>"><span>荐</span><?php echo $row['title']; ?></a></li>
<?php } ?>
<?php } ?>
代码语言:javascript复制
随机文章调用<?php getRandLog(6);?>
热门文章调用<?php getdatelogs(6);?>

0 人点赞