Typecho 笔记
Typecho 永久链接 设置伪静态
Typecho Apache 环境下伪静态规则,保存在网站根目录 .htaccess 文件中
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Typecho Nginx 环境伪静态规则,保存在 nginx.conf 配置文件中
if (!-e $request_filename) {
    rewrite ^(.*)$ /index.php$1 last;
}
未整理
typecho缩略图
主题直接提取缩略图代码
index.php
<?php
preg_match_all("/\<img.*?src\=(\'|\")(.*?)(\'|\")[^>]*>/i", $this->content, $matches);
$imgCount = count($matches[0]);
if($imgCount >= 1){
    $img = $matches[2][0];
echo <<<Html
 <a href="{$this->permalink}" title="{$this->title}" class="tu"><img src="{$img}?x-oss-process=style/szd2"  alt="{$this->title}" /></a>
Html;
}
?>
yijile2015模版所使用
index.php
<?php echo img_postthumb($this->cid); ?>
functions.php
/**
 * 输出文章缩略图
 *
 * @author ShingChi
 * @access public
 * @param int $width 缩略图宽度
 * @param int $height 缩略图高度
 * @return viod
 * @version Release 1.0.4
 */
function img_postthumb($cid) {
    $db = Typecho_Db::get();
    $rs = $db->fetchRow($db->select('table.contents.text')
        ->from('table.contents')
        ->where('table.contents.cid=?', $cid)
        ->order('table.contents.cid', Typecho_Db::SORT_ASC)
        ->limit(1));
    preg_match_all('/((http|https):\/\/)[0-9a-z\.\/]+(\.(jpg|jpeg|png|gif))/i', $rs['text'], $thumbUrl);
    //会错误获取一切网址 /http:\/\/[0-9a-z\.\/]+[.jpg|.png|.gif]/i
    //preg_match_all("/\<img.*?src\=\"(.*?)\"[^>]*>/i", $rs['text'], $thumbUrl);  //通过正则式获取图片地址
    $img_src = $thumbUrl[0][0];  //将赋值给img_src
    $img_counter = count($thumbUrl[0]);  //一个src地址的计数器
    switch ($img_counter > 0) {
        case $allPics = 1:
            echo '<span class="SpanPic"><img src="./plus/timthumb.php?zc=1&h=130&w=200&src=';
            echo $img_src;  //当找到一个src地址的时候,输出缩略图
            echo '" alt="缩略图"></span>';
            break;
        default:
            echo ""; //没找到(默认情况下),不输出任何内容 echo(rand(1,3));  echo "http://placekitten.com/42";echo(rand(0,9));echo "/19";echo(rand(0,9));
    };
}
/**
 * 输出文章缩略图
 *
 * @author ShingChi
 * @access public
 * @param int $width 缩略图宽度
 * @param int $height 缩略图高度
 * @return viod
 * @version Release 1.0.4
 */
function img_cover($cid) {
    $db = Typecho_Db::get();
    $rs = $db->fetchRow($db->select('table.contents.text')
        ->from('table.contents')
        ->where('table.contents.cid=?', $cid)
        ->order('table.contents.cid', Typecho_Db::SORT_ASC)
        ->limit(1));
    preg_match_all('/((http|https):\/\/)[0-9a-z\.\/]+(\.(jpg|jpeg|png|gif))/i', $rs['text'], $thumbUrl);
    $img_src = $thumbUrl[0][0];
    $img_counter = count($thumbUrl[0]);
    switch ($img_counter > 0) {
        case $allPics = 1:
            echo $img_src;
            break;
        default:
            echo ""; //没找到(默认情况下),不输出任何内容 echo(rand(1,3));  echo "http://placekitten.com/42";echo(rand(0,9));echo "/19";echo(rand(0,9));
    };
}
typecho相关教程
- typecho按需求输出缩略图
 - Typecho二次开发 文章表添加新字段 - Codeinto
 - typecho 归档页面调用自定义模版 - 李军博客 - blog by lijun
 - 安装typecho后出现数据库错误Database Query Error的解决办法汇总 开启typecho调试模式
 - 一个SQL语句删除TYPECHO的待审核评论 测试无法执行
 
旧收藏文章
- 注明文章版权信息以及相关日志 - typecho折腾小记一 - 彼岸雨云
 - 访客评论足迹插件 - 快乐学习 - 不烦恼
 - CMS主题及绑定插件开发规范 - 快乐学习 - 不烦恼
 - 强制评论包含中文字符(应gongyiyi要求) « Typecho 讨论区
 - 再发一个验证码的插件,图形拖拽验证! « Typecho 讨论区
 - WAP插件BufannaoWap提供下载 « Typecho 讨论区
 - 插件开发 - Typecho
 - 改动两种优化两种评论功能。 - 分享 - Web博客
 - 给最新发布的文章加张“new”的图片 - 分享 - Web博客
 - Typecho用来做CMS - 分享 - Web博客
 - Typecho 博客添加相关文章功能的方法 - 博客吧
 - typecho插件:调用typecho文章的第一个图片 - 跑调生活志
 - 正在使用的 Typecho 插件 - LinMuMu
 - Typecho主题制作常用代码 - 彼岸雨云
 - 输出摘要中的IMG - typecho折腾小记二 - 彼岸雨云
 - Gravatar头像缓存插件V2.0.0 - 彼岸雨云
 - 评论模块个性化 - typecho折腾小记三(12.27) - 彼岸雨云
 - typecho插件实现新注册用户为“贡献者” - 快乐学习 - 不烦恼
 - 关于typecho标题的优化 - 快乐学习 - 不烦恼
 - 自动产生缩略名的typecho插件 - caixw.com
 - 给Typecho开启GZIP压缩 - 分享 - Web博客
 - Typecho自定义页面模版使用中的一些记录 - 分享 - Web博客
 - 登录后文章方可见 - 分享 - Web博客
 - Typecho读者墙 - 分享 - Web博客
 - 给Typecho评论加个编辑器 - 分享 - Web博客
 - Typecho非插件读者墙 - N的试验田
 - typecho非插件实现读者墙 - 阅心笔记
 - typecho 非插件实现Archives(归档列表) - 蓝冰.net
 - Typecho灯箱插件slimbox2不显示图片、图片一直在加载、404错误解决方案 - 土豆不好吃
 - 使用TimThumb自动生成完美缩略图 - 微狐网
 
 
 
 本文采用 CC BY-NC-SA 4.0方式授权。 
 转载请注明出处和本文链接,说明是否进行修改,不得用于商业用途,使用相同方式共享。