【发布时间】:2012-01-29 21:13:46
【问题描述】:
Joomla 中有没有扩展搜索引擎的模块!还要在文章中按作者 (created_by) 和作者别名 (created_by_alias) 进行搜索?
我想为这个意图做一个简单的插件,但首先我简单地尝试修改 plugins/search/content.php 文件如下:
case 'exact':
$text = $db->Quote( '%'.$db->getEscaped( $text, true ).'%', false );
$wheres2 = array();
$wheres2[] = 'a.title LIKE '.$text;
$wheres2[] = 'a.introtext LIKE '.$text;
$wheres2[] = 'a.fulltext LIKE '.$text;
$wheres2[] = 'a.metakey LIKE '.$text;
$wheres2[] = 'a.metadesc LIKE '.$text;
$wheres2[] = 'a.created_by_alias LIKE '.$text; // added
$where = '(' . implode( ') OR (', $wheres2 ) . ')';
break;
case 'all':
case 'any':
default:
$words = explode( ' ', $text );
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote( '%'.$db->getEscaped( $word, true ).'%', false );
$wheres2 = array();
$wheres2[] = 'a.title LIKE '.$word;
$wheres2[] = 'a.introtext LIKE '.$word;
$wheres2[] = 'a.fulltext LIKE '.$word;
$wheres2[] = 'a.metakey LIKE '.$word;
$wheres2[] = 'a.metadesc LIKE '.$word;
$wheres2[] = 'a.created_by_alias LIKE '.$word; // added
$wheres[] = implode( ' OR ', $wheres2 );
}
$where = '(' . implode( ($phrase == 'all' ? ') AND (' : ') OR ('), $wheres ) . ')';
break;
在 exact 和 default 情况下,但没有运气。当我按作者别名搜索时,它不会按预期返回结果。事实是它返回相同的结果。
我必须修改其他文件吗?
提前致谢
PS:我正在使用 Joomla! 1.5
【问题讨论】:
-
我确定您可能已经这样做了 - 但作为安全措施,请确保您使用模板覆盖来实现这一点,而不是修改核心,因此在未来的升级中您的工作不会被消灭!我知道这有点离题 - 但认为信息越多越好!关于你的话题,恐怕我没有太多的帮助,对不起!
-
@Hanny 我有这个想法。我现在正在使用开发服务器。因此,在阅读有关模板覆盖的信息之前,我想知道这是否可行。感谢您的反馈!