Saturday, February 7, 2009

Optimize the default search options

By default the Joomla search searches for any word. That is if you look for "Joomla components", you will find any page which contains either Joomla or components. People require AND search. The following hack to the core code will enable all words searching by default.

In /components/com_search/search.html.php:

Find: $searchphrase = strtolower( strval( mosGetParam( $_REQUEST, 'searchphrase', 'any' ) ) );
Change to: $searchphrase = strtolower( strval( mosGetParam( $_REQUEST, 'searchphrase', 'all' ) ) );
This occurs twice in approximaletely lines 126 and 215

Also, in /components/com_search/search.php:

Find: $searchphrase = mosGetParam( $_REQUEST, 'searchphrase', 'any' );

Change to: $searchphrase = mosGetParam( $_REQUEST, 'searchphrase', 'all' );
This occurs in approximately line 103


Rememer to make a backup of each files in case something goes wrong.

No comments:

Post a Comment