在Joomla中搜索created_by_alias字段!内容

时间:2011-12-29 12:50:43

标签: joomla joomla-extensions

是否有一个扩展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

1 个答案:

答案 0 :(得分:1)

尝试将其置于默认情况下

$ wheres2 [] ='a.created_by_alias LIKE'。$ word;

你必须做更多的修改..

在文件的末尾,它调用函数checkNoHTML 寻找包含这个的行     if(searchHelper :: checkNoHTML($ article,$ searchText,array('text','title','metadesc','metakey')))

将其替换为

if(searchHelper::checkNoHTML($article, $searchText, array('text', 'title', 'metadesc', 'metakey','created_by_alias')))   // just added created_by_alias in last array parameter

现在在上面的所有查询中,在选择字段列表中添加“a.created_by_alias”