Joomla – Increase the Search Character Limit

by Elaine on February 9, 2011

I don’t know why there is a search character limit in the search box in Joomla, but there is one.   I find it extremely annoying.  You can test it out on your own Joomla website and see the you are restricted to only enter in 20 characters in the search box.   To resolve this you can either choose to install a different search component, or modify the existing code for the search component.   If you choose the latter, you will have to make code changes in the backend of your Joomla website.  Please make backups of all the files you change.    You will be accessing your website in the backend via FTP or a file manager and make changes to 4 files: mod_search.php, default_form.php, administrator search.php, and en-GB.com_search.ini.    If you want to increase your search character limit to 50, here are the code changes below.

1.  Edit this file ‘/modules/mod_search.php

Delete this line:

$maxlength        = $width > 20 ? $width : 20;

Add this line:

$maxlength        = $width > 50 ? $width : 50;

2.  Edit this file ‘/Components/com_search/views/search/tmpl/default_form.php

Delete this line:

<input id=”search_searchword” maxlength=”20″ name=”searchword” size=”30″ value=”<?php echo $this->escape($this->searchword); ?>” type=”text”>

Add this line:

<input id=”search_searchword” maxlength=”50″ name=”searchword” size=”30″ value=”<?php echo $this->escape($this->searchword); ?>” type=”text”>

3.  Edit this file ‘/administrator/Components/com_search/helpers/search.php

Remove these lines:

// limit searchword to 20 characters
if ( JString::strlen( $searchword ) > 20 ) {
$searchword     = JString::substr( $searchword, 0, 20 );

Add these lines:

// limit searchword to 50 characters
if ( JString::strlen( $searchword ) > 50 ) {
$searchword     = JString::substr( $searchword, 0, 49 );

4.  Edit this file ‘/language/en-GB/en-GB.com_search.ini

Delete this line:

SEARCH_MESSAGE=Search term must be a minimum of 3 characters and a maximum of 20 characters.

Add this line:

SEARCH_MESSAGE=Search term must be a minimum of 3 characters and a maximum of 50 characters.

Remember to save all your files.  Refresh your Joomla website and your search character restriction should have increased to 50 characters.  I don’t feel so cramped anymore, I can type whatever I want in my search box.

 Joomla   Increase the Search Character Limit

Elaine

Elaine is the founder of CmsMind, an online blog providing Joomla and Wordpress tutorials. Elaine lives in Toronto and when she is not online, she is either Marathon and Triathlon training or travelling and racing somewhere in the world. Find her also at: Save Money, Premium Themes and Templates, and at Webhosting Tips.

More Posts - Website

{ 9 comments… read them below or add one }

Arna Fríða Ingvarsdóttir August 11, 2011 at 2:30 pm

I have been looking all over for instructions how to change the word search limit… I have seen similar instructions as this one but when I open the files my search word limit says:
$maxlength = $upper_limit;
upper limit says:
$upper_limit = $lang->getUpperLimitSearchWord();

Can anyone help me on how to change this. I am very new to Joomla and I really don’t know php that well and don’t want to up my system :)
Thanks in advance :) :) :)

Reply

luca September 27, 2011 at 4:06 pm

I have the same Problem of Arna…any suggestions??? :(

Reply

ekallio January 17, 2012 at 9:37 am

If your using Joomla 1.7 ->
just modify the language files
/administrator/language/xx-XX/xx-XX.localise.php
and /language/xx-XX/xx-XX.localise.php

From there you’ll find Lower and Upper limits.
Error message is auto-generated from these numbers.

Reply

mario March 22, 2012 at 4:23 pm

This seems not to be valid for 2.5…I searched for // limit searchword to 20 characters into and other lines in administrator/components/com_Search/helpers/search.php without finding it…

Reply

Elaine March 22, 2012 at 7:08 pm

Hi Mario,
Sorry, I will create a new post for Joomla 2.5 for you….sometime this week or next. Will let you know when it’s complete.
Thanks for your visit,
elaine

Reply

Elaine March 23, 2012 at 3:53 am

Hi Mario,
I created a post for you on How to Increase the search character limit from 20 to a higher number. The post is here:

Joomla 2.5 – How to Increase Search Character Limit

I hope that helps you. Thanks for your visit,
elaine

Reply

Belinda October 28, 2012 at 9:14 pm

Hi,
I have suddenly Joomla advertisements on my frontpage only and on the “second” page, there are my “real” frontpage. I have been playing with menbers and groups, but can’t get it to work and it was in that process, that this happened. Hope you can help me.

This is some of the text:

Joomla!

Congratulations! You have a Joomla site! Joomla makes it easy to build a website just the way you want it and keep it simple to update and maintain.

Joomla is a flexible and powerful platform, whether you are building a small site for yourself or a huge site with hundreds of thousands of visitors. Joomla is open source, which means you can make it work just the way you want it to.”

Thanks Belinda

Reply

Belinda October 28, 2012 at 9:29 pm

Ah – I found it under Trash Articles and now they are gone :-)

Reply

gandhi March 21, 2013 at 2:25 pm

this for joomla2.5

/administrator/language/xx-XX/xx-XX.localise.php
and /language/xx-XX/xx-XX.localise.php
and change in module width also 50

Reply

Leave a Comment

Captcha Captcha Reload

Older Post:

Newer Post: