1)给typecho增加编辑当前文件功能,修改index.php或者post.php文件,添加

<li>
    <div class="edit">
        <?php if($this->user->hasLogin()):?>
            <a href="<?php $this->options->adminUrl(); ?>write-post.php?cid=<?php echo $this->cid;?>" target="_blank">编辑</a>
        <?php endif;?>
    </div>
</li>

2)typecho的表格太丑了,改style.css,添加

table {
    width: 100%;
    max-width: 65em;
    border: 1px solid #dedede;
    border-collapse: collapse;
    empty-cells: show;
}

table th,
table td {
    height: 35px;
    border: 1px solid #dedede;
    padding: 0 10px;
}

table th {
    font-weight: bold;
    text-align: center !important;
    background: rgba(158, 188, 226, 0.2);
}

table tbody tr:nth-child(2n) {
    background: rgba(158, 188, 226, 0.12);
}

table tr:hover {
    background: #efefef;
}

table th {
    white-space: nowrap;
}

3)typecho的数字也太丑了,修改style.ccs

font-family:"Source Sans Pro", "Helvetica Neue", Arial, sans-serif;

4)为Typecho增加文章阅读次数统计功能。
文章次数统计是比较常用的功能,下面通过修改代码实现统计。
控制台 / 外观 / 编辑当前外观 / 在 functions.php 加入以下代码
代码已中加入了cookie验证,让文章浏览次数更具有真实性
阅读次数记录在 db._contents.views表中

function Postviews($archive) {
    $db = Typecho_Db::get();
    $cid = $archive->cid;
    if (!array_key_exists('views', $db->fetchRow($db->select()->from('table.contents')))) {
        $db->query('ALTER TABLE `'.$db->getPrefix().'contents` ADD `views` INT(10) DEFAULT 0;');
    }
    $exist = $db->fetchRow($db->select('views')->from('table.contents')->where('cid = ?', $cid))['views'];
    if ($archive->is('single')) {
        $cookie = Typecho_Cookie::get('contents_views');
        $cookie = $cookie ? explode(',', $cookie) : array();
        if (!in_array($cid, $cookie)) {
            $db->query($db->update('table.contents')
                ->rows(array('views' => (int)$exist+1))
                ->where('cid = ?', $cid));
            $exist = (int)$exist+1;
            array_push($cookie, $cid);
            $cookie = implode(',', $cookie);
            Typecho_Cookie::set('contents_views', $cookie);
        }
    }
    echo $exist == 0 ? '   暂无阅读' :'   阅读量:' .$exist;
}

文章页post.php页,首页index.php调用<?php Postviews($this); ?>即可。
5)Typecho点赞功能开发
6)MWordStar 是一套简洁的 Typecho 双栏博客主题。主题Github上免费开源
7)Typecho点赞功能2
8)

标签: none

添加新评论