/****************************************************************************************************/ if($keyword != '') { if(!empty($typeid)) { $typeid ="AND arc.typeid IN($typeid) AND arc.id<>'$aid' "; } $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `dede_archives` arc LEFT JOIN `dede_arctype` tp ON arc.typeid=tp.id where arc.arcrank>-1 AND ($keyword) $typeid $orderquery limit 0, $row"; } else { if(!empty($typeid)) { $typeid = " arc.typeid IN($typeid) AND arc.id<>'$aid' "; } $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `dede_archives` arc LEFT JOIN `dede_arctype` tp ON arc.typeid=tp.id WHERE arc.arcrank>-1 AND $typeid $orderquery limit 0, $row"; } /*********************************************************************************************/ |
从上面的代码可以看到,织梦dedecms为了排除本文在程序一开头就试图过滤本文(AND arc.id<>'$aid' "),但是没成功,那怎么才能成功排除当前文章呢?很简单,我们在这段代码:AND ($keyword) $typeid 重新排除一次就可以,两段代码都要加,改完之后如下(注意看绿色加粗代码的地方有什么不同):
if($keyword != '') { if(!empty($typeid)) { $typeid ="AND arc.typeid IN($typeid) AND arc.id<>'$aid' "; } $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `dede_archives` arc LEFT JOIN `dede_arctype` tp ON arc.typeid=tp.id where arc.arcrank>-1 AND ($keyword) $typeid AND arc.id<>'$aid' $orderquery limit 0, $row"; } else { if(!empty($typeid)) { $typeid = " arc.typeid IN($typeid) AND arc.id<>'$aid' "; } $query = "SELECT arc.*,tp.typedir,tp.typename,tp.corank,tp.isdefault,tp.defaultname,tp.namerule, tp.namerule2,tp.ispart,tp.moresite,tp.siteurl,tp.sitepath FROM `dede_archives` arc LEFT JOIN `dede_arctype` tp ON arc.typeid=tp.id WHERE arc.arcrank>-1 AND $typeid AND arc.id<>'$aid' $orderquery limit 0, $row"; } |
到此,大功告成,赶紧去试试吧。
Pbootcms问题解决
请点击在线联系我们【点击咨询解决问题】 如果您有任何Pbootcms问题,我们将免费为您写解决教程!