在 Joomla! 中搜索 created_by_alias 字段!内容

发布于 2024-12-23 11:15:12 字数 1585 浏览 1 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热血少△年 2024-12-30 11:15:12

尝试将其放在默认情况下

$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”选择字段列表

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

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

now in all the queries above add "a.created_by_alias" in the select field list

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文