记录学习与后端知识并分享学习代码过程(会飞的鱼Blog)

emlog文章调用列表+今日更新红色标题+置顶单独代码

会飞的鱼 1 3283 2018年7月24日

将一下函数代码放在模板的module.PHP里

<?php //自己写的最新文章调用函数
date_default_timezone_set('Asia/Shanghai');
function aizhanyunblog_new($num){
    $db=mysql::getInstance();
    $n = $db->query("SELECT gid ,title FROM " . DB_PREFIX . "blog WHERE hide='n' and type='blog' and top='y' ORDER BY date DESC");
    $nums = $db->num_rows($n);
    while ($rows = $db->fetch_array($n)){
        $rows['title'] = htmlspecialchars($rows['title']);
     ?>
    <li><img src="//f162.cn.cn/zb_users/theme/aizhanyunblog/style/img/740.gif" alt="会飞对鱼" class="themeauthor" style="opacity: 1;">&nbsp;<em style="color:#1B00FF;font-style:normal !important;"><b>[置顶]</b></em>
      <a href="<?php echo url::log($rows['gid']); ?>" title="<?php echo $rows['title']; ?>" ><b><?php echo $rows['title']; ?></b></a></li>
    <?php }
    $log_range = '';
    if($nums > 0){
        $n2 = $db->query("SELECT gid FROM " . DB_PREFIX . "blog WHERE hide='n' and type='blog' and top='y' ORDER BY date DESC");
        while ($rows2 = $db->fetch_array($n2)){
        $log_range.= ' gid != '.$rows2['gid'].' and ';
        }
    }
    $log_num = $num - $nums;
    $logs = $db->query("SELECT gid ,title ,date FROM " . DB_PREFIX . "blog WHERE hide='n' and type='blog' and $log_range gid != 0 ORDER BY date DESC LIMIT 0, $log_num");
    while ($row = $db->fetch_array($logs)){
        $row['title'] = htmlspecialchars($row['title']);
     ?>
    <li><img src="//f162.cn/zb_users/theme/aizhanyunblog/style/img/740.gif" alt="hony" class="themeauthor" style="opacity: 1;">&nbsp;<a href="<?php echo Url::log($row['gid']); ?>" title="<?php echo $row['title']; ?>" ><b style="display:inline-block;line-height:16px;<?php echo gmdate('m-d', $row['date'])==date('m-d')?'color:red':null ?>"><?php echo mb_substr($row['title'],0,18,'utf-8');?></b></a><span style="float:right;<?php echo gmdate('m-d', $row['date'])==date('m-d')?'color:red':null ?>"><?php echo gmdate('m-d',$row['date']);?></span>
    </li>
    <?php }
}
?>

前台调用php

<div class="CMSlist cmslist2">
<?php aizhanyunblog_new(20);?>
</div>

css代码

//这里是css浮动代码,需要自行防御css文件里即可
.cmslist ul{padding: 3.5px 0;}
.cmslist li{height:28px;line-height:28px;font-size:14px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}
.cmslist li time{margin-left:5px;}
.cmslist2{float:none;width:100%;min-height:240px;}
.cmslist2 ul{overflow:hidden;}
.cmslist2 li{float:left;width:310px;margin:0 30px 0 0;}
本文由 @会飞的鱼 于 2018-7-24 发布在 会飞的鱼Blog,如无特别说明,本博文章均为原创,转载请保留出处。

网友评论当前共有1条评论

会飞的鱼 在线咨询

在线时间:9:00-22:00
周六、周日:14:00-22:00