Joomla 2.5 Tutorial – I don’t know why Joomla decided to make these values so hard to change. In Joomla 2.5, there is a minimum and maximum search word limit. The minimum search character length is 3 and maximum is 20. This tutorial is for Mario who left me a comment under an older post and asked me how to Increase the Search Character Limit in Joomla 2.5. I searched everywhere to change this value, and took me over an hour to finally find the solution.
Problem: How to Change Search Box:
- Minimum SearchWord Character Limit = 3; Want to change it to 1
- Maximum SearchWord Character Limit = 20; Want to Increase it to 50
High Level Solution:
- Use FTP Manager to Edit files or
- SSH into your domain file directory and edit the file
../language/[site-language]/[site-language].localise.php
- Change the limit values
Follow the detail steps below to Decrease/Increase the Minimum and Maximum Search Character Limit:
1. FTP or SSH into your Domain and Change Directory
Use your FTP Manager or SSH into your domain. You will need to edit files that are not editable in the Joomla 2.5 administrator backend.
- Use FTP Manager or SSH into your Domain name
- change directory to – /language/[site-language]
- Edit your – [site-language].localise.php
- For example, I have an english site, so I will edit the following file:
../language/en-GB/en-GB.localise.php
2. Change the Limit Values
If you SSH into your Domain, use your favourite editor, example pico or VI. Pico would probably easier. FTP Manager is best for those who do not know how to use either. In the file en-GB.localise.php, do the following:
a. Decrease the Minimum Search Character Limit – currently 3 change to 1
- Search for the following code
public static function getLowerLimitSearchWord() {
return 3;
}
- Change the code to the following – in red:
public static function getLowerLimitSearchWord() {
//Elaine CmsMind.com Mar 22, 2012 – Change Min Search Character limit to 1
//return 3;
return 1;
}
b. Increase the Maximum Search Character Limit – currently 20 change to 50
- Search for the following code
public static function getUpperLimitSearchWord() {
return 20;
}
- Change the code to the following – in red:
public static function getUpperLimitSearchWord() {
//Elaine CmsMind.com Mar 22, 2012 – Change Max Search Character limit 50
//return 20;
return 50;
}
Save the file and refresh your Joomla 2.5 website. I tested it and now I can add more characters to my search box.
Thanks. I hope this helps you. Let me know if you need more clarification.
Elaine
Thanks for this! I found an older tutorial for Joomla 1.5 which led me astray. I never even realized Joomla restricted searches to 20 characters until a client complained about it today. Do you know if we can put the en-GB.localise.php file in the new language overrides folder, so it won’t be overwritten each time Joomla is upgraded?
Cheers,
Chris
Hi,
in our directory can not found en-GB.localise.php file.
Hi Adib,
What language are you using?
Elaine
Super!!!!
This is GREAT!! It did the trick for me. Thank you so much!!!!
Hi Lisa,
No problem! Glad I was able to help.
Thanks for your visit,
elaine
Thanks Elaine, that’s nice.
As an added consideration, were migrating a massive site, and expecting a huge 404 fallout.
I’m working on the concept of being able to grab the existing url from Google, grab the page title, and put that into the searchbox (hence I was looking to increase the limit of the text and found your site 😉
here’s some example code, play and modify to suit
<?php
$requri = getenv ("REQUEST_URI");
$servname = getenv ("SERVER_NAME");
echo "Page not found: ” . $servname . $requri ;
?>
<?php
$urlContents = file_get_contents("http://webcache.googleusercontent.com/search?q=cache:". $servname . $requri);
preg_match("/(.*)/i”, $urlContents, $matches);
print($matches[1] . “\n”); // “Example Web Page”
?>
<input name="searchword" id="mod-search-searchword" maxlength="50" class="inputbox" type="text" size="35" value="” onblur=”if (this.value==”) this.value=’Search…’;” onfocus=”if (this.value==’Search…’) this.value=”;”>
thanks
Thanks, that work fine for me, this is the best solution to increase the joomla search
Elaine dear..You have always been an angel to me as far as my joomla issues are concerned..Thanks again
Hi JRD,
Thanks for your kind comment. 🙂
elaine
Great, It worked for me 😀
Increased the Search Character Limit in Joomla 2.5 by changing digits in a file you mentioned) thx