在 Joomla! 中搜索 created_by_alias 字段!内容
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;
在精确和默认情况下,但没有运气。当我按作者别名搜索时,它没有按预期返回结果。事实是它返回相同的结果。
我必须修改其他文件吗?
预先感谢
PS:我正在使用 Joomla! 1.5
Is there a module to extend the search engine in Joomla! to search also by author (created_by) and author alias (created_by_alias) in articles?
I was thinking make a simple pluging for this intention but first i simple tried modified the plugins/search/content.php file as follows:
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;
in the exact and default cases but without luck. It does not return the results as expected when I search by an author alias. The fact is that it returns the same results.
Do I must modify other files?
Thanks in advance
PS: I'm using Joomla! 1.5
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将其放在默认情况下
$wheres2[] = 'a.created_by_alias LIKE '.$word;
你必须做更多的修改..
在文件末尾它调用函数 checkNoHTML
查找包含此的行
if(searchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey')))
替换它现在
在上面的所有查询中添加“a.created_by_alias”选择字段列表
try putting this in default case
$wheres2[] = 'a.created_by_alias LIKE '.$word;
you have to do few more modifications..
at the end of the file it call as function checkNoHTML
look for line containing this
if(searchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey')))
replace it by
now in all the queries above add "a.created_by_alias" in the select field list