phpcmsV9解决lists标签加上where其他条件失效问题

最近使用PHPCMS建站需要二次开发功能,但是在解决lists标签加上where后,有些其他条件失效,这个问题怎么解决呢。经过查找相关资料,齐鲁建站小编找到不错的解决方法,今天就来说说的phpcms解决where失效方法。

下面就来说说phpcms解决where失效的方法。

问题描述:

{pc:content action="lists" catid="$catid" where="posids`!='0'" thumb="1" num="10"}

发现不是调用当前栏目而是全部栏目的,并且不管有没有缩略图都显示出来,发现这个问题存在很久了。

今天我们说一下怎么修复吧。

打开/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解决where失效的所有内容,有需要的朋友可以试试看。

极客网企业会员

免责声明:本网站内容主要来自原创、合作伙伴供稿和第三方自媒体作者投稿,凡在本网站出现的信息,均仅供参考。本网站将尽力确保所提供信息的准确性及可靠性,但不保证有关资料的准确性及可靠性,读者在使用前请进一步核实,并对任何自主决定的行为负责。本网站对有关资料所引致的错误、不确或遗漏,概不负任何法律责任。任何单位或个人认为本网站中的网页或链接内容可能涉嫌侵犯其知识产权或存在不实内容时,应及时向本网站提出书面权利通知或不实情况说明,并提供身份证明、权属证明及详细侵权或不实情况证明。本网站在收到上述法律文件后,将会依法尽快联系相关文章源头核实,沟通删除相关内容或断开相关链接。