JoomlaJoomla ComponentsJoomla Setup

Joomla – Increase the Search Character Limit

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.

  1. Arna Fríða Ingvarsdóttir

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

  2. ekallio

    If your using Joomla 1.7 ->
    just modify the language files
    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.

  3. mario

    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…

    1. Elaine

      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,

  4. Belinda

    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:


    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

  5. gandhi

    this for joomla2.5

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

Leave a Reply to Elaine Cancel reply

Your email address will not be published. Required fields are marked *

Captcha Captcha Reload