目的:实现pjax为了让音乐背景插件可以在切换网页时,不会切断重新开始,所以这个技术实现了某个部分不刷新。
1、在footer.php的</body>前面添加
<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的<body>之后添加
<div id="container">
在footer.php的<?php $this->footer(); ?>之前添加
</div>
Typecho的插件是把需要添加在页面的HTML代码插入到这里:
<?php $this->footer(); ?>,
所以为了不让音乐播放器被添加到#container的div中,
我将<?php $this->footer(); ?>放在了id为container的div之后。
index.php的$this->title(),前面加上 $this->sticky(); 保存post.php找到<?php $this->need('comments.php'); ?>改为<?php $this->need('comments.php1'); ?>(彻底关闭评论)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;
}