Emlog Fly模板/文章页添加作者信息代码方法(非插件)

效果图:QQ图片20190522201759.png

方法:

1、打开模板下的echo_log.php文件  把下面代码添加到想要显示的位置。 我添加在内容结束 后面 看下图

ttt.jpg

代码内容

<!-- 文章作者信息 -->
<div id="authorarea"><div class="authorinfo">
<?php global $CACHE; $user_cache = $CACHE->readCache('user'); $name = $user_cache[1]['mail'] != '' ? "<a href=\"mailto:".$user_cache[1]['mail']."\">".$user_cache[1]['name']."</a>" : $user_cache[1]['name'];?>
<div class="author-avater">
<?php 
function index_authorimg($uid){
	global $CACHE;
	$user_cache = $CACHE->readCache('user');
  	$img = $user_cache[$uid]['avatar'];
  	echo '<img alt="头像" src="'.BLOG_URL.$img.'">';
if($userinfo['descriptiondescription'] == '') $userinfo['description'] = "这家伙很懒,什么都没写!";
}
?>
<?php index_authorimg($author); ?></div>
<?php $DB = Database::getInstance();
$userData = $DB->once_fetch_array("SELECT * FROM ".DB_PREFIX."user WHERE uid = '$author'");
$userinfo = LoginAuth::getUserDataByLogin($userData['username']);
$userinfo['comnum'] = $DB->fetch_array($DB->query("select count(*) as nums from ".DB_PREFIX."comment where mail='".$userinfo['email']."'"));
$userinfo['comnum'] = $userinfo['comnum']['nums'];
$userinfo['blognum'] = $DB->fetch_array($DB->query("select count(*) as nums from ".DB_PREFIX."blog where author='$author'"));
$userinfo['blognum'] = $userinfo['blognum']['nums'];
?>

<div class="author-des">
<div class="author-meta">
<span class="post-author-name"><a href="<?php echo BLOG_URL; ?>?author=1"  rel="author"><?php blog_author($author); ?></a></span>
<?php $sta_cache = Cache::getInstance()->readCache('sta'); ?>
<span class="post-author-tatus"><a href="javascript:void(0);" target="_blank"><?php echo $userinfo['blognum'];?>篇文章</a></span>
<span class="post-author-tatus"><a href="javascript:void(0);" target="_blank"><?php echo $userinfo['comnum'];?>条评论</a></span>
<span class="post-author-weibo"><a href="<?php echo BLOG_URL.'author/'.$author ?>" rel="nofollow" target="_blank">TA主页</a></span>
<span class="post-author-weibo"><a href="tencent://message/?uin=<?php echo htmlspecialchars($userinfo['qq']);?>" rel="nofollow">联系Ta</a></span>
<span class="post-author-weibo"><a href="#" rel="nofollow" target="_blank">熊账号</a></span>
      </div>
	  <span class="user-counter-value">描述:</span>
							<span class="user-counter-key"><?php echo htmlspecialchars($userinfo['description']);?></span>
</div></div>
</div>
<!-- 文章作者信息 -->

2、将CSS添加到  style.css 里面即可

.post-author-url a, .post-author-weibo a {
    font-size:12px;
    text-decoration:none;
    padding:1px 8px;
    white-space:nowrap;
    margin-left:10px;
    -webkit-border-radius:20px;
    -moz-border-radius:20px;
    border-radius:20px;
    border-style:solid;
    border-width:1px
}
.post-author-weibo a {
    border-color:#32a5e7;
    color:#32a5e7
}
.post-author-weibo a:hover {
    background-color:#32a5e7;
    color:#fff
}
RIPRO主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
诗宇源码 » Emlog Fly模板/文章页添加作者信息代码方法(非插件)

提供最优质的资源集合

立即查看 了解详情