自制Typecho文章过时提醒!更高程度的自定义

这是什么玩意?

如题,鉴于对Typecho自带的文章过时提醒不满意,便魔改了主题自制了文章过时提醒233333。
Typecho自带的过时提醒不能修改显示提示的门槛天数,也不能修改文字内容以及样式,比较死板。
于是乎我就魔改了主题,新增了这个功能,用自己的方法。

效果演示

QQ截图20191102232231.png

食用方法

本文以handsome主题为例!
找到文件/usr/themes/handsome/post.php
找到大约第91行附近
在<div class="entry-content l-h-2x">的下一行添加:

<?php
$days_publish = round ((time() - $this->date->timeStamp) / (60 * 60 * 24));
$days_modified = round ((time() - $this->modified) / (60 * 60 * 24));
if($days_publish >= 40):
?>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>过时提醒:</strong>本文编写于<?=$days_publish?>天前,最后编辑于<?=$days_modified?>天前,部分内容可能过时,请您注意。
</div>
<?php endif; ?>

提醒门槛天数可以按照您的需求自行修改,比如这里面是40天。
提醒的文本内容和样式也可以按照您的需求自行修改。
用于handsome主题是基于bootstrap,我就直接利用了bootstrap的组件。

历史评论 8 条

保留原来的留言与回复。新的讨论请使用下方评论区。

  1. 冲冲冲ヾ(≧∇≦*)ゝ

    1. @Bhao , φ( ̄∇ ̄o)诶嘿嘿,布好酱

  2. 我自己写了一个,没想到刚写不久主题就更新这个功能了...........

  3. 非技术的路过。

  4. 为啥国外IP还无法访问网站啊_(:з)∠)_。。。

    1. @ , 之前出了点问题,禁止了国外的访问。现在可以辽qwq

  5. 小凛太强了

    1. @ohmyga , QAQ。。。我很菜

留言