首页
留言反馈
网站导航
推荐
毒鸡汤
Search
1
非插件为typecho 文章生成微海报分享
18,891 阅读
2
主题移动端,样式下添加二级分类
15,428 阅读
3
主题 添加author page
14,738 阅读
4
主题添加移动端下边栏
12,750 阅读
5
EMlog添加评论者邮箱等级
9,097 阅读
typecho
dynamic
SuiYu
Emlog
xiuno
登录
/
注册
Search
标签搜索
代码
xiuno
php
css
typecho
评论
模板
say
js
修改教程
标签
珍惜
努力
recommend
善良
样式
调用
微笑
颜色
插件
Vincent
累计撰写
151
篇文章
累计收到
184
条评论
首页
栏目
typecho
dynamic
SuiYu
Emlog
xiuno
页面
留言反馈
网站导航
推荐
毒鸡汤
搜索到
5
篇与
的结果
2021-07-03
Xiuno程序全部版块列表页面
首先添加路由,在插件hook目录新建文件index_route_case_start.php,内容为case 'bbs': include _include('plugin/xxx/view/htm/bbs.htm'); break;其中xxx修改为所在插件目录然后在/plugin/xxx/view/htm新建bbs.htm,内容为<?php include _include(APP_PATH . 'view/htm/header.inc.htm'); ?> <div class="row"><div class="col-lg-9 main"> <!--{hook bbs_start.htm}--> <ul class="list-unstyled mb-0"> <div class="row mx-0"><?php foreach ($forumlist_show as $_forum) { ?> <li class="col-sm-6 px-0 px-sm-2" fid="<?php echo $_forum['fid']; ?>" data-active="fid-<?php echo $_forum['fid']; ?>"> <div class="card mb-2"> <div class="card-body"> <div class="media"> <img class="logo-4 mr-2" src="<?php echo $_forum['icon_url']; ?>"> <div class="media-body"> <div class="d-flex justify-content-between"> <div><a href="<?php echo url("forum-$_forum[fid]"); ?>"><?php echo '' . $_forum['name'] . ''; ?></a></div> </div> <div class="text-small"> <?php echo "全部" . lang('threads') . ':'; ?><?php echo $_forum['threads']; ?> / <?php echo "今日" . lang('posts') . ':'; ?><?php echo $_forum['todayposts']; ?> </div> <div class="text-small break-all"> <?php echo xn_substr($_forum['brief'], 0, 18); ?> </div> </div> </div> </div> </div> </li> <?php } ?> </div> </ul> </div> <!--{hook bbs_end.htm}--> <!-- 此处省略了侧边栏代码,需要的话从别的页面复制过来--> </div> </div> <?php include _include(APP_PATH . 'view/htm/footer.inc.htm'); ?> <script> $('li[data-active="bbs"]').addClass('active'); </script> <!--{hook bbs_js.htm}-->
2021年07月03日
1,477 阅读
0 评论
5 点赞
2021-01-04
主题移动端,样式下添加二级分类
1. 代码修改header.php 相关j-sidebar-xs中的部分,主要是替换下面这一部分 <div class="card"> <div class="title">类目归类</div> <ul class="category-nav"> <?php while ($categorys->next()) : ?> <?php $children = $categorys->getAllChildren($categorys->mid); ?> <?php if ($categorys->levels === 0): ?> <?php if (empty($children)): ?> <li class='<?php if ($this->is('category', $categorys->slug)) _e("active"); ?>'> <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"> <path d="M325.31499999 764.323l1e-8-508.83099999c0-28.16 22.598-50.934 50.757-50.93400001 13.09300001 0 24.932 5.024 33.901 13.092l335.755 251.633c22.24 16.859 26.905 48.607 10.044 71.024-2.87099999 3.947-6.281 7.355-10.045 10.045l-339.338 254.51c-22.241 16.676-54.16 12.193-70.844-10.225-6.996-9.15-10.225-19.73-10.225-30.31v0z" p-id="6117"></path> </svg> <a href="<?php $categorys->permalink(); ?>"><?php $categorys->name(); ?></a> </li> <?php else: ?> <li class='<?php if ($this->is('category', $categorys->slug)) _e("active"); ?>'> <svg viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"> <path d="M325.31499999 764.323l1e-8-508.83099999c0-28.16 22.598-50.934 50.757-50.93400001 13.09300001 0 24.932 5.024 33.901 13.092l335.755 251.633c22.24 16.859 26.905 48.607 10.044 71.024-2.87099999 3.947-6.281 7.355-10.045 10.045l-339.338 254.51c-22.241 16.676-54.16 12.193-70.844-10.225-6.996-9.15-10.225-19.73-10.225-30.31v0z" p-id="6117"></path> </svg> <a href="<?php $categorys->permalink(); ?>"><?php $categorys->name(); ?> <span><i class="icon iconfont icon-Chevronrighticon text-right"></i><i class="icon iconfont icon-Chevrondownicon text-down"></i></span> </a> <ul> <?php foreach ($children as $mid):?> <?php $child = $categorys->getCategory($mid); ?> <li <?php if($this->is('category', $child['slug'])): ?> class="active"<?php endif; ?>> <a href="<?php echo $child['permalink'] ?>" title="<?php echo $child['name']; ?>"><?php echo $child['name']; ?></a> </li> <?php endforeach; ?> </ul> </li> <?php endif; ?> <?php endif; ?> <?php endwhile; ?> </ul> </div>2. 添加js 控制 $('.j-sidebar-xs .item.category ul li a').unbind().bind('click',function (ev) { let c = $(this); c.parent().siblings(".active").toggleClass("active") if(c.next().is("ul") && c.parent().toggleClass("active") && ev.preventDefault()) return false; })3. 添加css .item.category{ ul.category-nav li ul{ display: none; padding-left: 2.5em; opacity: 0; height: 0; overflow: auto; -webkit-transition: all .2s ease-in-out 0s; transition: all .2s ease-in-out 0s; li:last-child{ border-bottom: none; } } ul.category-nav li a { span{ float: right; } .text-down{ display: none; } } ul.category-nav li.active { ul { display: block; opacity: 1; height: auto; } a .text-right{ display: none; } a .text-down{ display: block; } } } .j-sidebar-xs .content .item .card ul li { display: block; <!--将原来的flex改为block--> }
2021年01月04日
15,428 阅读
2 评论
17 点赞
2021-01-04
主题添加移动端下边栏
joe 主题移动样式下面无法登录,所以索性给 joe 主题加上下边栏1.首先在component文件夹里新建一个footer.navimobi.php,其中JNavigation是我自己之前美化加的,你可以换成自己的链接。 <?php /** * 手机底部列表菜单 */ if (!Helper::options()->JMobiset) return; //$settings = Helper::options()->JNavmobi; $all = Typecho_Plugin::export(); $loginUrl = $this->options->loginUrl; if (array_key_exists('TePass', $all['activated'])){ if ($this->user->hasLogin()) $loginUrl = $this->options->index.'/admin/extending.php?panel=TePass/theme/ucenter/profile.php'; else $loginUrl = $this->options->index.'/tepass/signin'; } ?> <nav class="navigation-tab"> <!-- --><?php // $navtops_list = array(); // if (strpos($settings,'||')) { // //解析关键词数组 // $kwsets = array_filter(preg_split("/(\r|\n|\r\n)/",$settings)); // foreach ($kwsets as $kwset) { // $navtops_list[] = explode('||',trim($kwset)); // } // } // ?> <div class="navigation-tab-item"><a href="<?php echo $this->options->index ?>" target="_self"><span class="navigation-tab__icon"><i class="iconfont icon-iconfont icon-zhuye"></i></span></a></div> <div class="navigation-tab-item"><a href="<?php echo $loginUrl ?>" target="_blank"><span class="navigation-tab__icon"><i class="iconfont icon-iconfont icon-denglu"></i></span></a></div> <div class="navigation-tab-item <?php if ($this->is('page')) _e('active'); ?>" id="load_mobinav"><a href="<?php echo $this->options->JNavigation ?>" target="_self"><span class="navigation-tab__icon"><i class="iconfont icon-iconfont icon-paihangbang"></i></span></a></div> <div class="navigation-tab-item" id="mob_goTop"><a><span class="navigation-tab__icon"><i class="iconfont icon-iconfont icon-gotop"></i></span></a></div> <div class="navigation-tab-overlay"></div> </nav> 2.然后在functions.php里面加上一个开关 // 手机底部导航栏样式 $JMobiset = new Typecho_Widget_Helper_Form_Element_Select('JMobiset',array(0=>'不开启',1=>'开启'),0,'<h2>移动设置 Info</h2><hr>移动底部菜单设置','移动端页脚底部菜单'); $JMobiset->setAttribute('class', 'j-setting-content j-setting-index'); $form->addInput($JMobiset);3.在 public/config.php 里面(顶部)引入我们刚刚的文件<?php $this->need('component/footer.navmobi.php'); ?>最后加上控制js和 样式css $(".navigation-tab-item").bind('click',function() { $(".navigation-tab-item").removeClass("active"); $(this).addClass("active"); $(".navigation-tab-overlay").css({ left: 25 * $(this).prevAll().length + "%" }) }) $("#mob_goTop").click(function () { $("#backToTop").click() }) let load_mobi = $('#load_mobinav') if (load_mobi.hasClass('active')){ $(".navigation-tab-overlay").css({ left: 25 * load_mobi.prevAll().length + "%" }) }4.以下代码为scss ,自己手动转css @media (max-width: 768px) { .navigation-tab { display: flex !important; } } /* navigation-tab */ .navigation-tab{ height: 60px; width: 100%; line-height: 1; background-color: #fff; box-shadow: 0px 0px 20px -5px rgba(158, 158, 158, 0.22); overflow: hidden; border: 10px solid #fff; display: none; flex-shrink: 0; position: fixed; bottom: 0; z-index: 40; .navigation-tab-item{ display: flex; flex-direction: column; align-items: center; justify-content: center; width: 25%; flex-shrink: 0; line-height: 1; cursor: pointer; transition: 0.3s; position: relative; z-index: 2; &.active { width: 25%; } .navigation-tab__icon { display: block; color: #4298e7; transition-duration: 0.3s; line-height: 1; svg{ width: 24px; height: 24px; fill:#4298e7; } i{ font-size: 24px; } } } .navigation-tab-overlay { border-radius: 20px; background-color: #e4f2ff; height: 100%; width: 25%; position: absolute; left: 0; top: 0; transition: 0.3s; } }
2021年01月04日
12,750 阅读
0 评论
9 点赞
2021-01-04
主题 添加author page
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; } } }
2021年01月04日
14,738 阅读
1 评论
13 点赞
2021-01-04
主题添加互动读者及读者等级
1. 我们先在function.php里面添加一个开关 $JactiveUsers = new Typecho_Widget_Helper_Form_Element_Radio( 'JactiveUsers', array( 1 => '开启', 0 => '关闭', ),0,'是否开启互动读者','介绍:显示评论相关用户' ); $JactiveUsers->setAttribute('class', 'j-setting-content j-setting-aside'); $form->addInput($JactiveUsers);2. 然后我们可以给侧栏加代码了aside.php 里面对应位置添加,位置和其他啥广告位的一样不多说 <!--互动读者--> <?php if ($this->options->JactiveUsers and $this->is('index')): ?> <section class="aside aside-hunter-authors"> <h3 class="aside-title"><i class="icon iconfont icon-wodeguanzhu"></i> <span><?php _e('互动读者'); ?></span></h3> <div class="hunter-cont"> <ul class="hunter-authors"> <?php $period = time() - 2592000; // 单位: 秒, 时间范围: 30天 $counts = Typecho_Db::get()->fetchAll(Typecho_Db::get() ->select('COUNT(author) AS cnt', 'author', 'max(authorId) authorId', 'max(mail) mail') ->from('table.comments') ->where('created > ?', $period) ->where('status = ?', 'approved') ->where('type = ?', 'comment') ->group('author') ->order('cnt', Typecho_Db::SORT_DESC) ->limit('4') ); $mostactive = ''; $viphonor = Helper::options()->themeUrl('assets/img/authen.svg','Typecho-Joe-Theme'); foreach ($counts as $count) { $imgUrl = ParseAvatar($count['mail'],1); if ($count['authorId'] == '0') { $c_url = '<li><div class="item"><div class="hunter-avatar"><div class="vatar"><img src="' . $imgUrl . '"></div></div><div class="item-main"><div>' . $count['author'] . ''; } else { $c_url = '<li><div class="item"><div class="hunter-avatar"><a href="' . $this->options->siteUrl . 'index.php/author/' . $count['authorId'] . '" ><div class="vatar"><img src="' . $imgUrl . '"><img class="va_v_honor" src="' . $viphonor . '" title="认证用户"></div></a></div><div class="item-main">' . $count['author'] . ''; } echo '' . $c_url . ''; autvip($count['mail']); $allpostnum = allpostnum($count['authorId']); echo ' <h4>评论 ' . $count['cnt'] . ' 次 | <i>'.$allpostnum.'</i>'; echo ' </h4></div></div></li>'; } ?> </ul> </div> </section> <?php en#dif; ?>3. 我们在functions.php 或者 core.php 添加一些辅助函数函数函数加一些辅助函数数 /** * 显示用户等级,按邮箱 */ function autvip($i){ $db=Typecho_Db::get(); $mail=$db->fetchAll($db->select(array('COUNT(cid)'=>'rbq'))->from('table.comments')->where('mail = ?', $i)/**->where('authorId = ?','0')**/); foreach ($mail as $sl){ $rbq=$sl['rbq'];} if($rbq<1){ echo '<span class="autlv aut-0">Lv.0</span>'; }elseif ($rbq<10 && $rbq>0) { echo '<span class="autlv aut-1">Lv.1</span>'; }elseif ($rbq<20 && $rbq>=10) { echo '<span class="autlv aut-2">Lv.2</span>'; }elseif ($rbq<40 && $rbq>=20) { echo '<span class="autlv aut-3">Lv.3</span>'; }elseif ($rbq<80 && $rbq>=40) { echo '<span class="autlv aut-4">Lv.4</span>'; }elseif ($rbq<100 && $rbq>=80) { echo '<span class="autlv aut-5">Lv.5</span>'; }elseif ($rbq>=100) { echo '<span class="autlv aut-6">Lv.6</span>'; } } /**输出作者文章总数,可以指定*/ function allpostnum($id){ $db = Typecho_Db::get(); $postnum=$db->fetchRow($db->select(array('COUNT(authorId)'=>'allpostnum'))->from ('table.contents')->where ('table.contents.authorId=?',$id)->where('table.contents.type=?', 'post')); $postnum = $postnum['allpostnum']; if($postnum=='0') { return '暂无文章'; } else{ return '文章 '.$postnum.' 篇'; } }4. 最后就是添加样式了scss样式如下,需要css 的可以自己转一下 .autlv { font-size: 10px; color: #fff; display: inline-block; vertical-align: text-top; font-weight: normal; border-radius: 2px; line-height: 1.4; padding: 0 4px; margin-left: 5px; letter-spacing: 0px; } .aut-0 { background: #d1d5dc; } .aut-1 { background: #448EF6; } .aut-2 { background: #f6b044; } .aut-3 { background: #c444f6; } .aut-4 { background: #f69644; } .aut-5 { background-image: -webkit-linear-gradient(0deg, #3ca5f6 0%, #a86af9 100%); } .aut-6 { background: #f64444; } .aside-hunter-authors{ background: var(--background); .vs { border-radius: 100%; } ul{ padding: 14px; list-style: none; line-height: 2.5; } .item{ border-bottom: 1px dashed #eee; margin-bottom: 0px; position: relative; padding-bottom: 4px; .hunter-avatar{ float: left; line-height: 55px; .vatar{ position: relative; img{ width: 45px; border-radius: 100%; } .va_v_honor{ position: absolute; bottom: 3px; right: 0px; width: 18px; height: 18px; } } } .item-main{ min-height: 60px; margin-left: 60px; color: #393939; h4{ font-size: 12px; line-height: 1; margin-bottom: 7px; font-weight: normal; color: #999; i{ font-style: normal; color: #aaa; margin: 0 5px; } } } } }转载于:即刻学术
2021年01月04日
3,016 阅读
4 评论
10 点赞