解决lists标签中,加上where后其他条件失效的问题

问题描述:
{pc:content action="lists" catid="$catid" where="posids`!='0'" thumb="1" num="10"}
发现不是调用当前栏目而是全部栏目的,并且不管有没有缩略图都显示出来,在PHPCMS官方论坛搜索了一下,发现这个问题存在很久了。今天我们说一下怎么修复吧!

打开/phpcms/modules/content/classes/目录下的content_tag.class.php这个文件,把下面的代码(大概第63行)

  1. f(isset($data['where'])) { 
  2. $sql = $data['where']; 
  3. else { 
  4. $thumb = intval($data['thumb']) ? " AND thumb != ''" : ''
  5. if($this->category[$catid]['child']) { 
  6. $catids_str = $this->category[$catid]['arrchildid']; 
  7. $pos = strpos($catids_str,',')+1; 
  8. $catids_str = substr($catids_str, $pos); 
  9. $sql = "status=99 AND catid IN ($catids_str)".$thumb; 
  10. else { 
  11. $sql = "status=99 AND catid='$catid'".$thumb; 

替换为下面的代码即可。


  1. if(isset($data['where'])) { 
  2. $where = (isset($data['where'])&&(!empty($data['where'])))?' AND '.$data['where']:''
  3. $thumb = intval($data['thumb']) ? " AND thumb != ''" : ''
  4. if($this->category[$catid]['child']) { 
  5. $catids_str = $this->category[$catid]['arrchildid']; 
  6. $pos = strpos($catids_str,',')+1; 
  7. $catids_str = substr($catids_str, $pos); 
  8. $sql = "status=99".$where." AND catid IN ($catids_str)".$thumb; 
  9. else { 
  10. $sql = "status=99".$where." AND catid='$catid'".$thumb; 
  11. else { 
  12. $thumb = intval($data['thumb']) ? " AND thumb != ''" : ''
  13. if($this->category[$catid]['child']) { 
  14. $catids_str = $this->category[$catid]['arrchildid']; 
  15. $pos = strpos($catids_str,',')+1; 
  16. $catids_str = substr($catids_str, $pos); 
  17. $sql = "status=99 AND catid IN ($catids_str)".$thumb; 
  18. else { 
  19. $sql = "status=99 AND catid='$catid'".$thumb; 







联系我们

在线咨询:点击这里给我发消息

邮件:w420220301@qq.com