分类 Typecho 下的文章

https://prismjs.com/
进入下载页 选择 Languages Themes
下载 JS CSS
将 prism.js prism.css 上传至 /usr/themes/default
在 header.php </head>前插入

<link rel="stylesheet" href="<?php $this->options->themeUrl('prism.css'); ?>">
<script src="<?php $this->options->themeUrl('prism.js'); ?>"></script>

在代码块标记 ``` 后添加语言名

wget https://github.com/typecho/typecho/releases/latest/download/typecho.zip
unzip typecho.zip
安装时上传目录无法写入:chmod o+w uploads

/usr/local/nginx/conf/vhost/host.conf
后台404:将 enable-php.conf 改为 enable-php-pathinfo.conf
IP地址访问网站:server_name 添加IP地址
重启nginx:/usr/local/nginx/sbin/nginx -s reload

侧边栏不显示最近回复与其他:
/themes/default/sidebar.php 注释 ShowRecentComments ShowOther
或者在 控制台 设置外观 去勾选 显示最近回复 显示其他杂项

禁用评论:控制台 个人设置 撰写设置 默认允许 去勾选 可以被评论

不显示"评论":/themes/default/index.php 注释 interactionCount
不显示点击作者后的"评论":/themes/default/archive.php 注释 interactionCount

自定义后台路径:config.inc.php define('__TYPECHO_ADMIN_DIR__', '/admin/');

后台不显示"最近得到的回复":index.php 注释 '最近得到的回复'对应的div

首页不显示"关于":/themes/default/header.php 注释 \Widget\Contents\Page 至 endwhile

修改主题下的index.php

将如下代码放在$this->need('header.php');

/** 文章置顶 */
$sticky = '1'; //置顶的文章id,多个用|隔开
if($sticky){
    $sticky_cids = explode('|',$sticky); //分割文本

    $db = Typecho_Db::get();
    $pageSize = $this->options->pageSize;
    $select1 = $this->select()->where('type = ?', 'post');
    $select2 = $this->select()->where('type = ? && status = ? && created < ?', 'post','publish',time());

    //清空原有文章的列队
    $this->row = [];
    $this->stack = [];
    $this->length = 0;

    $order = '';
    foreach($sticky_cids as $i => $cid) {
        if($i == 0) $select1->where('cid = ?', $cid);
        else $select1->orWhere('cid = ?', $cid);
        $order .= " when $cid then $i";
        $select2->where('table.contents.cid != ?', $cid); //避免重复
    }
    if ($order) $select1->order('', "(case cid$order end)"); //置顶文章的顺序 按 $sticky 中 文章ID顺序
    if ($this->_currentPage == 1) foreach($db->fetchAll($select1) as $sticky_post){ //首页第一页才显示
        $sticky_post['sticky'] = $sticky_html;
        $this->push($sticky_post); //压入列队
    }

    $uid = $this->user->uid; //登录时,显示用户各自的私密文章
    if($uid) $select2->orWhere('authorId = ? && status = ?',$uid,'private');

    $sticky_posts = $db->fetchAll($select2->order('table.contents.created', Typecho_Db::SORT_DESC)->page($this->_currentPage, $this->parameter->pageSize));
    foreach($sticky_posts as $sticky_post) $this->push($sticky_post); //压入列队
    $this->setTotal($this->getTotal()-count($sticky_cids)); //置顶文章不计算在所有文章内
}