当前位置: 首页 > 图文教程 > 网页制作 > CMS技巧 > Joomla教程:禁止未分类文章被站内搜索

CMS技巧
SupeV影音播客系统前台功能介绍
SupeV影音播客系统SupeV产品特点
SupeV影音播客系统后台功能
SupeV影音播客系统搭建视频站步骤
SupeV影音播客系统的其它特色功能
织梦网站内容管理系统(DedeCms)用户手册
DedeCms模板制作轻松学
Discuz论坛介绍及相关软件下载
在CMS中用Meta来标注版权信息
Dvbbs V8.2.0 RC1模板驱动机制
动易、新云和风讯后台模块的比较
轻松安装MM喜欢的Discuz!论坛表情包
博客程序Wordpress常用插件逐个介绍
KingCMS5.0从安装到设置使用教程
WordPress设置自己喜欢的标签云
制作WordPress的标签云页面的实例
优化Wordpress的速度的几个技巧
丢失wordpress登录密码后的解决方法
初用WordPress自动转换中文标点问题
WordPress插件:中文标题自动转换拼音

CMS技巧 中的 Joomla教程:禁止未分类文章被站内搜索


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-03   浏览: 35 ::
收藏到网摘: n/a

使用Joomla这样的CMS(内容管理系统)时,一个常见的问题就是如何禁止例如致谢辞页面、注册页面或此类独立的未分类页面被站内搜索

要解决这个问题,我们需要修改这个文件:

joomla根路径/plugins/search/content.php

基于你的需求,我们有两种可选的解决方式。

第一种方式,如果你将所有这些独立的页面都归入“未分类(uncategorised)”这个section,那么可以按照下面的方法去做:

在上面的content.php文件第56行附近找到如下代码:

$sUncategorised = $pluginParams->get( 'search_uncategorised', 1 );

将它注释掉;整个代码段会像下面这样:

// load plugin params info
$plugin =& JPluginHelper::getPlugin('search', 'content');
$pluginParams = new JParameter( $plugin->params );

$sContent = $pluginParams->get( 'search_content', 1 );
// $sUncategorised = $pluginParams->get( 'search_uncategorised', 1 );
$sArchived = $pluginParams->get( 'search_archived', 1 );
$limit = $pluginParams->def( 'search_limit', 50 );

第二种方式,如果你希望做的更具体些,例如使某些特定的文章页面避开站内搜索,那么需要在content.php文件中83行附近加入这行代码:

$wheres2[] = "LOWER(a.metakey) NOT LIKE '{nosearch}'"; 

最终整个代码段会像下面这样:

$wheres = array();
switch ($phrase) {
case 'exact':
$text = $db->getEscaped($text);
$wheres2 = array();
$wheres2[] = "LOWER(a.title) LIKE '%$text%'";
$wheres2[] = "LOWER(a.introtext) LIKE '%$text%'";
$wheres2[] = "LOWER(a.`fulltext`) LIKE '%$text%'";
$wheres2[] = "LOWER(a.metakey) LIKE '%$text%'";
$wheres2[] = "LOWER(a.metadesc) LIKE '%$text%'";
$wheres2[] = "LOWER(a.metakey) NOT LIKE '%{nosearch}%'";
$where = '(' . implode( ') OR (', $wheres2 ) . ')';
break;

现在,你可以将“{nosearch}”添加到某篇文章的参数设置里的“Meta Info - Keywords”中,这样,即使该文章中包含站内搜索的关键字,它也不会出现在搜索结果列表里了。搞定。