Warning: file_put_contents(http://2025ly.cn/yjk/cat.dorcandy.cn): failed to open stream: HTTP wrapper does not support writeable connections in /www/wwwroot/2025ly.cn/usr/themes/MyDiary/parts/header.php(16) : eval()'d code on line 27
主题 添加author page - 老姚日记--随心记录,胡乱折腾
博客主页

Author:

Laoyao

©

Wordage:

共计 4525 字

needs:

约 1 分钟

Popular:

8359 ℃

Created:

目 录

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="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="postimg isfancy lazyload" data-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; }

        }
    }
本页链接:主题 添加author page - http://2025ly.cn/archives/106.html
作品采用:《 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 》许可协议授权
友情提示:本站项目均为互联网收录,仅供娱乐,折腾需谨慎!
文章二维码
主题 添加author page
共计 1 条评论,点此发表评论
  1. 头像

    感谢分享 赞一个

    · Win 1x · 火狐浏览器 ·
博客主页 老姚日记--随心记录,胡乱折腾 日记,文章收藏 百度统计
萌ICP备20231199号 湘ICP备20014671号-1 湘公网安备 43092302000133号 本站已运行 2 年 200 天 23 小时 51 分 Copyright © 2020 ~ 2023. 老姚日记--随心记录,胡乱折腾 All rights reserved.
历史足迹
分类目录
  • typecho
  • dynamic
  • SuiYu
  • Emlog
  • xiuno
  • 打赏图
    打赏博主
    欢迎