首页
反馈
朋友
统计
更多
投稿
推荐
毒鸡汤
Search
1
主题 添加author page
7,980 阅读
2
主题移动端,样式下添加二级分类
7,964 阅读
3
主题添加移动端下边栏
7,914 阅读
4
EMlog添加评论者邮箱等级
5,344 阅读
5
Emlog模版文章页标题自动变颜色方法
5,279 阅读
typecho
dynamic
SuiYu
Emlog
xiuno
登录
Search
标签搜索
代码
xiuno
typecho
css
评论
say
php
模板
修改教程
js
recommend
善良
标签
珍惜
语法高亮
苦
惜
洒脱
认证
评论时间
emlly
累计撰写
133
篇文章
累计收到
140
条评论
首页
栏目
typecho
dynamic
SuiYu
Emlog
xiuno
页面
反馈
朋友
统计
投稿
推荐
毒鸡汤
搜索到
3
篇与
标签
的结果
2021-01-25
Emlog自动为文章标签添加该标签的链接
我们在编写文章时,经常需要添加一些标签的链接,这样不仅可以优化我们的内链,对用户来说也可以参照相关的文章,如果对文章的关键字进行手动添加链接,那样对我们来说太麻烦了,而且在标签关键词很多的情况下我们是记不住的,那怎么如何让Emlog站点的文章自动添加标签链接变为内链呢?其实我们只需要在主题目录下的module.php文件中添加一段代码就可以实现了。打开我们主题的module.php文件添加如下代码: /自动为文章标签添加该标签的链接 function tag_link($content){ global $CACHE; $tag_cache = $CACHE->readCache('tags'); foreach($tag_cache as $value){ $tag_url = Url::tag($value['tagurl']); $keyword = $value['tagname']; $cleankeyword = stripslashes($keyword); $url = "<a href=\"{$tag_url}\" title=\"浏览关于“{$cleankeyword}”的文章\" target=\"_blank\" >{$cleankeyword}</a>"; $regEx = '\'(?!((<.*?)|(<a.*?)))('. $cleankeyword . ')(?!(([^<>]*?)>)|([^>]*?</a>))\'s'; $content = preg_replace($regEx,$url,$content); } return $content; }其次在echo_log.php中将 <?php echo $log_content; ?> 修改成 <?php echo tag_link($log_content); ?> 即可。
2021年01月25日
4,219 阅读
0 评论
4 点赞
2020-09-28
typecho评论显示个性化自定义
typecho的官方博客有一篇文章专门讲诉typecho的评论自定义显示的,官方的不够直观,方法如下:在 comments.php 开头部份加入如下方法即可实现自定义。(解说可以查看注释)<?php function threadedComments($comments, $singleCommentOptions) { $commentClass = ''; if ($comments->authorId) { if ($comments->authorId == $comments->ownerId) { $commentClass .= ' comment-by-author'; } else { $commentClass .= ' comment-by-user'; } } $commentLevelClass = $comments->_levels > 0 ? ' comment-child' : ' comment-parent'; ?> <li id="<?php $comments->theId(); ?>" class="comment-body<?php if ($comments->_levels > 0) { echo ' comment-child'; $comments->levelsAlt(' comment-level-odd', ' comment-level-even'); } else { echo ' comment-parent'; } $comments->alt(' comment-odd', ' comment-even'); echo $commentClass; //以上部份 不用理会,是判断一些奇偶数评论和作者类的,下面的才是需要修改的,根据需要修改吧, php部份不需要 修改,只需要修改 HTML 部分,下面是我现在用的 ?>"> <div class="comment-author"> <?php $comments->gravatar($singleCommentOptions->avatarSize, $singleCommentOptions->defaultAvatar); //头像 只输出 img 没有其它标签 ?> <div class="comment-info"> <cite class="fn"><?php $singleCommentOptions->beforeAuthor(); $comments->author();$singleCommentOptions->afterAuthor(); //输出评论者 ?> </cite> <em class="comment-meta"> <a href="<?php $comments->permalink(); ?>"><?php $singleCommentOptions->beforeDate(); $comments->date($singleCommentOptions->dateFormat); $singleCommentOptions->afterDate(); //输出评论日期 ?></a> </em> </div> <div class="comment-reply"> <?php $comments->reply($singleCommentOptions->replyWord); //输出 回复 链接?> </div> </div> <?php $comments->content(); //输出评论内容,包含 <p></p> 标签 ?> <?php if ($comments->children) { ?> <div class="comment-children"> <?php $comments->threadedComments($singleCommentOptions); //评论嵌套?> </div> <?php } ?> </li> <?php } ?>下面是对应的CSS代码:隐藏内容,请前往内页查看详情
2020年09月28日
691 阅读
1 评论
2 点赞
2020-09-16
Typecho 标签云如何随机展示固定个数的标签
官方文档<?php $this->widget('Widget_Metas_Tag_Cloud', 'sort=mid&ignoreZeroCount=1&desc=0&limit=30')->to($tags); ?> <?php if($tags->have()): ?> <ul class="tags-list"> <?php while ($tags->next()): ?> <li><a href="<?php $tags->permalink(); ?>" rel="tag" class="size-<?php $tags->split(5, 10, 20, 30); ?>" title="<?php $tags->count(); ?> 个话题"><?php $tags->name(); ?></a></li> <?php endwhile; ?> <?php else: ?> <li><?php _e('没有任何标签'); ?></li> <?php endif; ?>参数说明sort:排序方式为 mid;ignoreZeroCount:忽略文章数为 0 的;desc:是否降序输出;limit:输出数目。在这里我们可以看到,官方给出的方法,只能固定排序方式和输出个数。而往往标签多了之后,我们使用该方法输出的标签云总是显示这些标签,这时我们想要每次展示的标签都不相同怎么办呢?方法其实很简单,既不用改typecho源码,也不用安装该类插件,只需要把排序方式的值改为rand()即可。$this->widget('Widget_Metas_Tag_Cloud', 'sort=rand()&ignoreZeroCount=1&desc=0&limit=30')->to($tags);
2020年09月16日
761 阅读
0 评论
1 点赞