最新消息: 新版网站上线了!!!

PHPCMS 解决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行)

 

 
if(isset($data['where'])) {
    $sql = $data['where'];
else {
    $thumb = intval($data['thumb']) ? " AND thumb != ''" '';
    if($this->category[$catid]['child']) {
        $catids_str = $this->category[$catid]['arrchildid'];
        $pos = strpos($catids_str,',')+1;
        $catids_str = substr($catids_str, $pos);
        $sql = "status=99 AND catid IN ($catids_str)".$thumb;
    else {
        $sql = "status=99 AND catid='$catid'".$thumb;
    }
}

替换为下面的代码即可。

 

 
if(isset($data['where'])) {
    $where = (isset($data['where'])&&(!empty($data['where'])))?' AND '.$data['where']:'';
    $thumb = intval($data['thumb']) ? " AND thumb != ''" '';
    if($this->category[$catid]['child']) {
        $catids_str = $this->category[$catid]['arrchildid'];
        $pos = strpos($catids_str,',')+1;
        $catids_str = substr($catids_str, $pos);
        $sql = "status=99".$where." AND catid IN ($catids_str)".$thumb;
    else {
        $sql = "status=99".$where." AND catid='$catid'".$thumb;
    }
else {
    $thumb = intval($data['thumb']) ? " AND thumb != ''" '';
    if($this->category[$catid]['child']) {
        $catids_str = $this->category[$catid]['arrchildid'];
        $pos = strpos($catids_str,',')+1;
        $catids_str = substr($catids_str, $pos);
        $sql = "status=99 AND catid IN ($catids_str)".$thumb;
    else {
        $sql = "status=99 AND catid='$catid'".$thumb;
    }
}
 

转载请注明:谷谷点程序 » PHPCMS 解决lists标签加上where后其他条件失效的问题