4

密码保护:Typecho 文章部分加密和显示标题

 2 years ago
source link: https://blog.jinlife.com/index.php/archives/20/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

密码保护:Typecho 文章部分加密和显示标题

于 2021-03-16 由 jinlife 发布

typecho 部分功能使用确实不是很方便,需要修改源码才行,比如加密文章竟然不显示标题,这也是崩溃了,只好修改下源码

显示标题

编辑文件 var/Widget/Abstract/Contents.php,大概在 744 行左右,找到:

$value['title'] = _t('此内容被密码保护');

改成下面的这个,也就是注释注释掉这行就好了。

//$value['title'] = _t('此内容被密码保护');

文章部分加密

这里用到了 “<--more-->” 作为分割,“<--more-->” 的内容加密,也是修改 var/Widget/Abstract/Contents.php 文件:

$value['text'] = explode('<!--more-->', $this->markdown($value['text']))[0]. //前面是新增的部分代码
'<form class="protected" action="' . $this->security->getTokenUrl($value['permalink'])
                . '" method="post">' .
            '<p class="word">' . _t('请输入密码访问') . '</p>' .
            '<p><input type="password" class="text" name="protectPassword" />
            <input type="submit" class="submit" value="' . _t('提交') . '" /></p>' .
            '</form>';

或者 http://typecho-fans.github.io/plugins/ 里面的TitleShow

本文作者:jinlife
本文链接:密码保护:Typecho 文章部分加密和显示标题 - https://blog.jinlife.com/index.php/archives/20/
版权声明:本博客内容遵守 “署名-非商业性使用-禁止演绎 4.0 国际”协议(CC BY-NC-ND 4.0),除特别说明外内容皆为原创,可以自由转载与传播,但请署名及注明文章出处。



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK