目录
- Typecho实现pjax
- Typecho背景音乐
- Typecho实现文章置顶
- Typecho关闭评论
- 开启https(ssl)无法登陆后台
- 外链以新标签或新窗口打开
- 视频播放代码
- 实现伪静态(2018-03-04更新)
一、Typecho实现pjax
目的:实现pjax为了让音乐背景插件可以在切换网页时,不会切断重新开始,所以这个技术实现了某个部分不刷新。
1、在footer.php的前面添加
<script src="//cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
<script src="//cdn.bootcss.com/jquery.pjax/2.0.1/jquery.pjax.min.js"></script>
<script>
$(document).pjax('a[href^="<?php Helper::options()->siteUrl()?>"]:not(a[target="_blank"], a[no-pjax])', {
container: '#container',
fragment: '#container',
timeout: 8000
}).on('pjax:send',
function() {
}).on('pjax:complete',
function() {
});
</script>
以上三段code的顺序不能置换
2、添加内容变换容器
在header.php的之后添加
<div id="container">
在footer.php的<?php $this->footer(); ?>之前添加
</div>
第2步说明:
Typecho的插件是把需要添加在页面的HTML代码插入到这里:<?php $this->footer(); ?>,
所以为了不让音乐播放器被添加到#container的div中,
我将<?php $this->footer(); ?>放在了id为container的div之后。
参考文章:
二、Typecho背景音乐
- 下载插件YoDuBMG
- 优点:自动/手动播放、解析网易云音乐ID
三、Typecho实现置顶文章
- 下载插件Sticky
- 上传至yourwebsite/usr/plugins,并解压
- typecho后台插件管理,启用
- 插件设置,填入cid数字xxx,即编辑文章状态时,网页链接地址cid=xxx
- 外观管理,编辑外观,在index.php的$this->title(),前面加上
$this->sticky();保存
四、Typecho关闭评论
- 后台设置—评论,勾选文章*天后关闭评论(自定义关闭时间);
- 后台外观—编辑当前外观,在
post.php找到<?php $this->need('comments.php'); ?>改为<?php $this->need('comments.php1'); ?>(彻底关闭评论)
五、开启https(ssl)无法登陆后台
1.若出现,尝试修改伪静态规则如下
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php) {
rewrite (.*) $1/index.php;
}
if (!-f $request_filename) {
rewrite (.*) /index.php;
}
六、外链以新标签或新窗口打开
七、视频播放代码
- 在以下代码的src=""的""内填入可播放地址
- 参数可自定义
<iframe frameborder="0" width="100%" height="498" src="" allowfullscreen></iframe>
八、实现伪静态
- 如果是bt宝塔面板
- 在typecho,永久链接设置
- 启用:地址重写功能,
若保存后出现检测不到,则根据提示勾选再保存; - 选择你自己喜欢的url形式(除了默认),保存;
- 启用:地址重写功能,
- 在bt面板打开网站设置
- 点击伪静态,选择:typecho,保存;
- 重启nginx(apache),或重载配置
2.非ui面板
在nginx.conf里找到网站的server配置段,推荐如下的配置,修改yourdomain
server {
listen 80;
server_name yourdomain.com;
root /home/yourdomain/www/;
index index.html index.htm index.php;
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php$1 last;
}
location ~ .*\.php(\/.*)*$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
}
access_log logs/yourdomain.log combined;
}
apache配置,打开根目录下的.htaccess文件,没有的话就新建
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
caddy配置
yoursite.com {
tls yourmail@youermail.com
root /home/wwwroot/yoursite.com
gzip
fastcgi / 127.0.0.1:9000 php
rewrite / {
if {path} not_match (/usr/|/admin/)
to /index.php{uri}
}
}
以上,配置完成后,请重启相关服务,或重载配置