diff --git a/CateFilter/Plugin.php b/CateFilter/Plugin.php index 63db5c2f..1e669108 100644 --- a/CateFilter/Plugin.php +++ b/CateFilter/Plugin.php @@ -4,7 +4,7 @@ * * @package CateFilter * @author Rakiy - * @version 1.2.3 + * @version 1.2.4 * @link */ class CateFilter_Plugin implements Typecho_Plugin_Interface @@ -38,8 +38,14 @@ public static function deactivate(){} * @return void */ public static function config(Typecho_Widget_Helper_Form $form){ - $CateId = new Typecho_Widget_Helper_Form_Element_Text('CateId', NULL, '0', _t('首页不显示的分类'), _t('多个请用英文逗号隔开')); - $form->addInput($CateId); + + Typecho_Widget::widget('Widget_Metas_Category_List')->to($categories); + while($categories->next()){$cate[$categories->mid]=$categories->name;}//获取分类列表 + + $CateId = new Typecho_Widget_Helper_Form_Element_Checkbox('CateId', + $cate,[], _t('勾选首页不想显示的分类'), NULL); + $form->addInput($CateId->multiMode()); + } /** * 个人用户的配置面板 @@ -66,9 +72,8 @@ public static function personalConfig(Typecho_Widget_Helper_Form $form){} public static function filter($obj, $select){ //if('/feed' == strtolower(Typecho_Router::getPathInfo()) || '/feed/' == strtolower(Typecho_Router::getPathInfo())) return $select; $CateIds = Typecho_Widget::widget('Widget_Options')->plugin('CateFilter')->CateId; - if(!$CateIds) return $select; //没有写入值,则直接返回 + if(empty($CateIds)) return $select; //数组为空,则直接返回 $select = $select->select('table.contents.cid', 'table.contents.title', 'table.contents.slug', 'table.contents.created', 'table.contents.authorId','table.contents.modified', 'table.contents.type', 'table.contents.status', 'table.contents.text', 'table.contents.commentsNum', 'table.contents.order','table.contents.template', 'table.contents.password', 'table.contents.allowComment', 'table.contents.allowPing', 'table.contents.allowFeed','table.contents.parent')->join('table.relationships','table.relationships.cid = table.contents.cid','right')->join('table.metas','table.relationships.mid = table.metas.mid','right')->where('table.metas.type=?','category'); - $CateIds = explode(',', $CateIds); $CateIds = array_unique($CateIds); //去除重复值 foreach ($CateIds as $k => $v) { $select = $select->where('table.relationships.mid != '.intval($v))->group('cid');//确保每个值都是数字;排除重复文章 diff --git a/CateFilter/README.md b/CateFilter/README.md index d29a8445..228d5795 100644 --- a/CateFilter/README.md +++ b/CateFilter/README.md @@ -2,13 +2,16 @@ *** ##版本 - 1.2.3 + 1.2.4 ##说明 首页过滤指定分类 ##历史更新 + V1.2.4 2024.01.14 + 修复Typecho1.2.1勾选不上设置的问题 + V1.2.3 2022.04.03 删除原作者失效域名,优化一处写法