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

  • 内容
  • 相关

将一下函数代码放在模板的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;}

本文标签:

版权声明:若无特殊注明,本文皆为《会飞的鱼》原创,转载请保留文章出处。

本文链接:emlog文章调用列表+今日更新红色标题+置顶单独代码 - https://f162.cn/post/329

发表评论

电子邮件地址不会被公开。 必填项已用*标注

未显示?请点击刷新

允许邮件通知