Emlog读者墙美化代码

一、操作步骤

1、打开模板文件module.php,添加如下代码

 

<?php 
function guest($num){
	global $CACHE;
	$user_cache = $CACHE->readCache('user');
	$name = $user_cache[1]['name'];
	$DB = Database::getInstance();
	$sql = "SELECT count(*) AS comment_nums,poster,mail,url FROM ".DB_PREFIX."comment where date >0 and poster !='". $name ."' and  poster !='' and hide ='n' group by poster order by comment_nums DESC limit 0,$num";
	$log_content = $content[1];
	if(strpos($log_content, '[READERWALL-WEEK]') > -1) {
		$cur_time_span = strtotime('last Year',strtotime('Sunday'));
	}
	$result = $DB -> query( $sql );
	while($row = $DB -> fetch_array($result)){
		$img = "<li><a rel=\"external nofollow\" target=\"_blank\" href=\"" . $row[ 'url' ] . "\" title=\"" . $row[ 'poster' ] ."(赐教" . $row[ 'comment_nums' ] . "次)\"><img  alt=\"avatar\"  src=\"" . getGravatar($row['mail']) . "\" class=\"avatar\"><em>" . $row[ 'poster' ] ."</em><strong>+" . $row[ 'comment_nums' ] . "</strong></a></li>";
		if( $row[ 'url' ] ){
			$tmp = "<li><a rel=\"external nofollow\" target=\"_blank\" href=\"" . $row[ 'url' ] . "\" title=\"" . $row[ 'poster' ] ."\" ><img  alt=\"avatar\"  src=\"" . getGravatar($row['mail']) . "\"><em>" . $row[ 'poster' ] ."</em><strong>+" . $row[ 'comment_nums' ] . "</strong></a></li>";
		}else{
			$tmp = $img;
		}
		$output .= $tmp;
	}
	$output = ''. $output .'';
	return $output ;
}
?>

 

2、打开模板样式文件style.css,添加如下代码

 

ul.readers-list{overflow:hidden;margin:0 auto;padding:0;}
ul.readers-list li{display:inline-block;width:20%;}
ul.readers-list a{position:relative;display:block;overflow:hidden;margin:0 4px;padding:4px 4px 4px 44px;height:40px;border:1px solid #eaeaea;color:#999;text-decoration:none;line-height:32px;}
ul.readers-list img{float:left;margin:0 8px 0 -38px;width:30px;height:30px;border:3px #fff solid;border-radius:50%;background:#fff;box-shadow:0 1px 3px rgba(34,25,25,.5);}
ul.readers-list em{position:absolute;overflow:hidden;margin-right:10px;width:50%;height:36px;color:#000;text-overflow:ellipsis;white-space:nowrap;font-style:normal;transition:all .2s ease-out;}
ul.readers-list strong{position:absolute;right:8px;width:20%;color:#999;text-align:right;}

 

3、在侧边栏或单页面上添加如下引用代码即可

 

<ul class="readers-list"><?php echo guest(100); ?></ul>

 

二、原理解析

模板核心文件中添加读者墙功能代码,通过CSS对其进行美化,然后输出即可

三、注意事项

1、本教程中的引用代码推荐添加在单页面

THE END

作者信息

作者:Emlly

我不懒,我只是开启了节能模式

返回列表
没有咯
下一篇:

发表评论

快速评论:请填写QQ获取资料!

快捷回复:

未显示?请点击刷新