admin 2020-12-19 <?php while($this-> next()): ?> <?php if($this-> category != "say"): ?> //正常输出循环 <?php endif; ?> <?php endwhile; ?>最近在使用Typecho程序,用到了JOE主题,文章列表都带缩略图了,我习惯了文章有图就像是缩略图,无图就不显示。我有一个文章分类是纯文字的,所以我直接把它写死算了,排除这个分类,让它以纯文字的形式显示。这里用到的是分类的别名,代码如下:Typecho实现不同分类显示不同模板一般情况下,不同分类显示不同的模板,我们在CMS中比较常见,但在typecho这种轻量级的个人博客中,很少用到。我可能是少量中的那一部分吧,使用的主题只有一种模板,不能满足我的需求,只能在此基础上自定义了。给定每个分类一个别名,使用相同的文件名对应,然后通过判断即可。<?php if($this-> is('category','fenlei1')){ $this->need('fenlei1.php'); }elseif($this->is('category','fenlei2')){ $this->need('fenlei2.php'); }else{ $this->need('fenlei3.php'); } ?>
admin 2020-12-19 必应每日一图<?php $str=file_get_contents( 'https://cn.bing.com/HPImageArchive.aspx?idx=0&n=1' ); if (preg_match( "/<url>(.+?)<\/url>/ies" , $str, $matches)) { $imgurl= 'https://cn.bing.com' .$matches[ 1 ]; } if ($imgurl) { header( 'Content-Type: image/JPEG' ); @ob_end_clean(); @readfile($imgurl); @flush(); @ob_flush(); exit (); } else { exit ( 'error' ); } ?>