排行榜 统计
  • 建站日期:2020/07/11
  • 文章总数:151 篇
  • 评论总数:184 条
  • 分类总数:5 个
  • 最后更新:1月17日

主题 添加author page

本文阅读 1 分钟
首页 typecho 正文

本文最后更新于2022年12月23日, 已超过484天没有更新。 如果文章内容或图片资源失效,请留言反馈,我会及时处理,谢谢!

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; }

        }
    }
本文来自投稿,不代表本站立场,如若转载,请注明出处:
-- 展开阅读全文 --
主题添加互动读者及读者等级
« 上一篇 01-04
主题添加移动端下边栏
下一篇 » 01-04
V注册会员 L评论等级
R1 条回复
  1. 2021-03-22     Win 10 /    FireFox

    感谢分享 赞一个

没有更多评论了