AddTable}` a" />

百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>织梦CMS教程> 织梦DedeCMS限定搜寻指定栏目或模型的方法
分享文章到:

织梦DedeCMS限定搜寻指定栏目或模型的方法

发布时间:09/08 来源:未知 浏览: 关键词:
在实现网站的搜索过程中,我们不想让某些栏目下的文章被检索出来,此时需要对DedeCMS进行二次开发,主要实现方法有以下两种:
 
一、打开include/arc.searchview.class.php,找到以下代码(大概在第450行):
 
 
 $cquery = "SELECT * FROM `{$this->AddTable}` arc WHERE ".$this->AddSql;   
 
换成
 
 
$cquery = "Select * From `dede_archives` arc where arc.typeid not in (1,2,3...) and {$this->AddSql}";   
 
找到以下代码(大概在第661行):
 
 
//搜索
$query = "SELECT arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule,
act.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath
FROM `dede_archives` arc LEFT JOIN `dede_arctype` act ON arc.typeid=act.id
WHERE arc.id IN ($aids)";
 
换成
 
 
//搜索
$query = "Select arc.*,act.typedir,act.typename,act.isdefault,act.defaultname,act.namerule,
act.namerule2,act.ispart,act.moresite,act.siteurl,act.sitepath
from `dede_archives` arc left join `dede_arctype` act on arc.typeid=act.id
where act.id not in (4,5,,6....) and {$this->AddSql} $ordersql limit $limitstart,$row";
 
这样就可以屏蔽掉不需要被检索的栏目了。
 
二、我们还可以利用另外一个思路,直接在搜索页面里设置我们需要被检索的栏目即可,打开plus/search.php,找到以下代码(大概在第107行):
 
 
$sp = new SearchView($typeid,$keyword,$orderby,$channeltype,$searchtype,$starttime,$pagesize,$kwtype,$mid);
 
换成
 
 
$typeid=1;
$sp = new SearchView($typeid,$keyword,$orderby,$channeltype,$searchtype,$starttime,$pagesize,$kwtype,$mid);
 
数字即代表我们需要指定的栏目ID,这样就可以实现搜索指定的栏目了。
 
如果是要搜索某个内容模型中的文章,其他模型都不参与搜索,那么只需打开plus/search.php,找到以下代码(大概在第17行):
 
 
$channeltype = (isset($channeltype) && is_numeric($channeltype)) ? $channeltype : 0;
 
其中$channeltype就是指定搜索的内容模型,默认为0即搜索全部模型,我们需要将最后的数字修改为对应的内容模型即可。

 

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有159人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板