PDA

View Full Version : Change Joomla Search Word Limit


Olin Coles
26th February 2008, 10:31 AM
I recently tried to find information on how to easily change the searchword limit in Joomla, beyond the default value of 20 and found nothing of the sort in terms of a guide. So here's how I did it for Joomla version 1.0.15.

You will need to begin by setting the maximum number of characters you want the search box to display. This variable is set in the Modules - Site Modules - Search edit menu. Keep your characters inside the search box, or else you'll have long searches moving the entire site over.

Next, use a strong text editor or html editor to change variables in several key Joomla files. Some of these files may not be relevant to your change, but they all reference the searchword limit, so it's best to be thorough. Here are the steps to take if you want to change the searchword limit from 20 to 40 as an example:

components/com_search/search.html.php
Change: maxlength="20"
Into: maxlength="40"
components/com_search/search.html.php
Change: if ( strlen( $searchword ) > 20 ) {
Into: if ( strlen( $searchword ) > 40 ) {
modules/mod_search.php
Change: $width = intval( $params->get( 'width', 20 ) );
Into: $width = intval( $params->get( 'width', 40 ) );That's it! Once you have made these changes, your search word box will now use the specified number of characters in the performance of a search. But with all of the extra power, you might consider one last change.

To change the default value of the Joomla Search function from "Any Words" into "All Words", add the following line of code into components/com_search/search.php.

Below: $mainframe->setPageTitle( _SEARCH_TITLE );
Add: if($_REQUEST['searchphrase']=='') { $_REQUEST['searchphrase']=$_GET['searchphrase']='all'; }

Please post here if this was helpful to you, or there are any questions.

blucadet3
10th March 2008, 03:21 PM
Do you know how to do this in Joomla 1.5?

Thanks.

Olin Coles
10th March 2008, 03:54 PM
It's my understanding that this problem still exists in Joomla v1.51 (current version), and they are working on a fix for future versions. You might also try the instruction above to see if it has any effect.

blucadet3
12th March 2008, 07:54 AM
I did try. Thanks for your reply.

The code is the same, the file is default_form.php instead of search.html.php...

I made the changes, and I can enter more characters in the search box, but when I execute the search its still cut off. There must be another line of code in another file somewhere.

Thanks again.