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

作者 : 官方 本文共2073个字,预计阅读时间需要6分钟 发布时间: 2020-04-13 共178人阅读

将一下函数代码放在模板的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%20echo%20url::log($rows[‘gid’]);%20?>” 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%20echo%20Url::log($row[‘gid’]);%20?>” 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;}


IT速极网-【教程资源】 » emlog文章调用列表+今日更新红色标题+置顶单独代码

常见问题FAQ

RD.IT速极网可以技术支持吗?
需要技术技术资源联系客服即可!

发表评论