【问题标题】:Search created_by_alias field in Joomla! content在 Joomla! 中搜索 created_by_alias 字段!内容
【发布时间】: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;

exactdefault 情况下,但没有运气。当我按作者别名搜索时,它不会按预期返回结果。事实是它返回相同的结果。

我必须修改其他文件吗?

提前致谢

PS:我正在使用 Joomla! 1.5

【问题讨论】:

  • 我确定您可能已经这样做了 - 但作为安全措施,请确保您使用模板覆盖来实现这一点,而不是修改核心,因此在未来的升级中您的工作不会被消灭!我知道这有点离题 - 但认为信息越多越好!关于你的话题,恐怕我没有太多的帮助,对不起!
  • @Hanny 我有这个想法。我现在正在使用开发服务器。因此,在阅读有关模板覆盖的信息之前,我想知道这是否可行。感谢您的反馈!

标签: joomla joomla-extensions


【解决方案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”

【讨论】:

  • 我试过了,它对我有用。请出示您的代码。
  • 完美 :) 我错过了那部分。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2019-11-18
  • 2018-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多