1.在joe主题同级目录下添加一个author.php
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<?php
if (empty($this->uid)) {
$str = $_SERVER["REQUEST_URI"];
if (preg_match('/\d+/', $str, $arr)) {
$id = $arr[0];
if ($this->user->hasLogin() && $this->user->uid == $id) {
$lock = 0;
} else {
$lock = 1;
}
$info = userok($id);
$this->user->uid = $id;
$this->user->screenName = $info['screenName'];
$this->user->mail = $info['mail'];
$this->user->group = $info['group'];
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<?php $this->need('public/head.php'); ?>
</head>
<body>
<?php $this->options->JCustomBodyStart() ?>
<section id="joe">
<!-- 头部 -->
<?php $this->need('public/header.php'); ?>
<!-- 主体 -->
<section class="container j-index j-author">
<section class="j-adaption">
<div class="col-md-12">
<!--创作中心s-->
<header class="page-header">
<div class="author-header-meta">
<?php $email = $this->user->mail;
$imgUrl = ParseAvatar($email, 1);
echo '<img src="' . $imgUrl . '" class="avatar avatar-120 photo" height="50" width="50">'; ?>
<div class="name"><?php $this->user->screenName(); ?></div>
<div class="desc"><?php autvip($this->user->mail); ?></div>
<div class="desc">
<svg t="1608204283958" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3189" width="1em" height="1em"><path d="M826.46929 339.76682s19.698076 58.094327-94.090811 133.586954c0 0 55.19461-291.571526-302.170491-473.353774 0 0 99.090323 228.177717-108.089445 377.063177 0 0-78.792305-102.390001-226.677863-117.488526 0 0 61.394004 95.290694 56.394492 188.081633s-80.292159 196.880773-38.896201 328.567913c34.19666 108.789376 116.588614 214.879016 274.373206 247.775803-21.597891-54.894639-32.396836-112.589005 5.399472-261.774436 0 0 1.399863 123.587931 226.177913 255.275071 216.978811-57.494385 447.656284-264.574163 207.579728-677.733815z" p-id="3190" fill="#7a7b7c"></path></svg>
<?php echo allviewnum($this->user->uid); ?>
</div>
</div>
</header>
</div>
<section class="main <?php $this->options->JListType() ?>">
<div class="row author-page">
<div class="col-md-12">
<!--创作中心e-->
<section class="j-index-article article">
<!-- 列表 -->
<?php $this->need('component/index.list.php'); ?>
</section>
</div>
</section>
</section>
</section>
<!-- 尾部 -->
<?php $this->need('public/footer.php'); ?>
</section>
<!-- 配置文件 -->
<?php $this->need('public/config.php'); ?>
</body>
</html>
functions.php 或者 core.php
// 会员页判断是否会员id
function userok($id){
$db = Typecho_Db::get();
$userinfo=$db->fetchRow($db->select()->from ('table.users')->where ('table.users.uid=?',$id));
return $userinfo;
}
/**输出作者人气*/
function allviewnum($id){
$db = Typecho_Db::get();
$postnum=$db->fetchRow($db->select(array('Sum(views)'=>'allviewnum'))->from ('table.contents')->where ('table.contents.authorId=?',$id)->where('table.contents.type=?', 'post'));
$postnum = $postnum['allviewnum'];
if($postnum=='0')
{
return '暂无访问';
}
elseif ($postnum>=10000) {
return ' 1万+访问';
}
elseif ($postnum<10000 && $postnum>5000) {
return ' 5K+访问';
}
else{
return ' '.$postnum.' °c 访问';
}
}
3. 添加一点样式
.j-author{
.author-header-meta{
text-align: center;
margin: 50px 0;
.avatar { border-radius: 100%; margin-top: -10px; margin-bottom: 10px; position: relative; }
.name { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.desc { color: var(--routine); font-size: 14px; margin-bottom: 10px; }
}
}
评论