noneCms
noneCms copied to clipboard
bug
文件位置: application\common\taglib\Tag.php 问题: 条件:where status = 0 and cid = 13 or cid in (2,3,4)(当分类为子类时无法隐藏删除) 应改为:where status = 0 and cid = 13 or cid in (2,3,4) and status = 0;(不知如何用tp5连续操作表达) 所以改为一级分类不能添加文章,二级才能添加文章,也有利于站点结构 修改为: ` /** * 获取文章列表 / public function tagArticle($tag, $content) { $cid = isset($tag['cid']) ? $tag['cid'] : 0; $order = isset($tag['orderby']) ? $tag['orderby'] : ''; $limit = isset($tag['limit']) ? $tag['limit'] : 0; $pagesize = isset($tag['pagesize']) ? $tag['pagesize'] : 0; $field = isset($tag['field']) ? $tag['field'] : ''; $empty = isset($tag['empty']) ? $tag['empty'] : ''; $module = request()->module(); /$children_ids = Db::name('category')->where('pid',$cid)->field('id')->select(); print_r(array_column($children_ids,'id'));die;*/ $parse = <<<EOF <?php $condition['status'] = 0;
/*存在子类,则获取子类下的文章*/
if(!empty($cid)){
\$condition['cid'] = $cid;
\$children_ids = think\Db::name('category')->field('id')->where('pid',\$condition['cid'])->select();
\$children_ids = array_column(\$children_ids,'id');
}
\$list = think\Db::name('article');
if(isset(\$children_ids) && \$children_ids){
\$list = \$list->where(['status'=>0,'cid'=>['in',\$children_ids]]);
// \$list = \$list->where(\$condition);
}else{
\$list = \$list->where(\$condition);
}
if("$field" != ''){
\$list=\$list->field("$field");
}
if("$order" != ''){
\$list=\$list->order("$order");
}
if($pagesize > 0){
\$list=\$list->paginate($pagesize);
\$page = \$list->render();
}else{
if($limit != 0){
\$list=\$list->limit($limit);
}
\$list=\$list->select();
}
\$ss = think\Db::name('category')->getLastSql();
//dump(\$ss);
\$__LIST__ = \$list;
foreach(\$__LIST__ as \$key => \$article):
\$article['url'] = url('$module/show/index',['cid' => \$article['cid'],'id' => \$article['id']]);
\$article['litpic'] = empty(\$article['litpic'])?'http://wp.iyouths.org/wp-content/themes/yusi1.0/timthumb.php?src=http://wp.iyouths.org/wp-content/themes/yusi1.0/img/pic/'.rand(1,9).'.jpg&h=122&w=180&q=90&zc=1&ct=1':img_server().\$article['litpic'];
?>
EOF;
$parse .= $content;
$parse .= '<?php endforeach;?>';
return $parse;
}
`
已修复
还是抛出一个问题 [1] ErrorException in 16f8c6af2aeb74e99e4e6a878e7428db.php line 132
Call to undefined function array_column()
/*存在子类,则获取子类下的文章*/
if($cid){
$condition['cid'] = $cid;
$children_ids = think\Db::name('category')->field('id')->where('pid',$condition['cid'])->select();
$children_ids = array_column($children_ids,'id'); /***## 出错在这一行***/
}
$list = think\Db::name('article')->where($condition);
if(isset($children_ids) && $children_ids){
$list = $list->whereor('cid','in',$children_ids);
}
if("" != ''){
$list=$list->field("");
}
分析原因是PHP版本低于5.5的原因。nangge大是否应该做下兼容啊。 http://www.thinkphp.cn/code/335.html
已修复
为什么是js 分类, 而不是放到php 分类里面呢