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