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
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