How to override the searchword limit to be able to search for 21 or more chars?

For Joomla! 1.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
fbarros
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed May 30, 2007 7:50 pm
Location: Montevideo - Uruguay

How to override the searchword limit to be able to search for 21 or more chars?

Post by fbarros » Wed May 30, 2007 8:14 pm

I'm having this problem with joomla 1.5, I need to search for strings bigger than 21 chars, so I tried the following:
I modified helper.php in mod_search and default_form.php in com_search where it says maxlenght=20 for maxlength=50 but when I enter a search string of more than 20 chars joomla searches only for the first 19 chars!
if the search string has 20 or less chars joomla searchs correctly
I couldn't find any other file where there's an explicit limit for the searchword, anyone has solved this issue for joomla 1.5?
thanks!

User avatar
esedic
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 145
Joined: Wed Dec 27, 2006 1:55 pm
Contact:

Re: How to override the searchword limit to be able to search for 21 or more cha

Post by esedic » Mon Feb 04, 2008 9:34 am

I have the same problem and I couldn't find the solution.  :'(

Can somebody help, please!

cheers, es
http://www.spletodrom.com | Izdelava spletnih strani

User avatar
Robin
Joomla! Master
Joomla! Master
Posts: 15753
Joined: Thu Aug 18, 2005 10:41 am

Re: How to override the searchword limit to be able to search for 21 or more cha

Post by Robin » Mon Feb 04, 2008 9:40 am

Hi,

Check the Search module too, it has a template file which also contains the maxlength=20.

User avatar
esedic
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 145
Joined: Wed Dec 27, 2006 1:55 pm
Contact:

Re: How to override the searchword limit to be able to search for 21 or more cha

Post by esedic » Mon Feb 04, 2008 10:32 am

It was exactly that file that I have overlooked! It works now. :laugh:

Thank you very much for quick reply.
http://www.spletodrom.com | Izdelava spletnih strani

blucadet3
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Mon Mar 10, 2008 9:22 pm

Re: How to override the searchword limit to be able to search fo

Post by blucadet3 » Mon Mar 10, 2008 9:26 pm

I have changed that value, and it allows you to add more characters when filling out the search box, but when you execute the search it still cuts it off at 20. Is there something else I'm missing?

The site is http://www.justsoyouknow.us

Thanks.

User avatar
sassamifrass
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Fri Jun 08, 2007 8:02 am
Location: Western Australia

Re: How to override the searchword limit to be able to search fo

Post by sassamifrass » Wed Jun 25, 2008 9:14 am

We have this problem too, some people in our organisation have names that are longer than 20 characters! ;-)

We have the first part of the solution, based on the old one for 1.0.X. You need to change the component code. Go to the root of your Joomla install, then navigate to the path

administrator\components\com_search\helpers

Open up search.php

Around line 62 you will see

Code: Select all

// limit searchword to 20 characters
		if ( JString::strlen( $searchword ) > 20 ) {
			$searchword 	= JString::substr( $searchword, 0, 19 );
			$restriction 	= true;
		}
We wanted 40 characters, so we changed it to

Code: Select all

// limit searchword to 20 characters
		if ( JString::strlen( $searchword ) > 40 ) {
			$searchword 	= JString::substr( $searchword, 0, 39 );
			$restriction 	= true;
		}
HOWEVER this is not enough to fix everything... somewhere there is a limitation being set elsewhere (nom not in the backend module settings, we tried that) that restricts people from typing more than 20 characters at a time. We could find it in 1.0.X, but can't find it in 1.5 yet. Hope our partial solution inspires others to finish it.

We've been receiving complaints from visitors who can't search full names... I understand that unlimited search queries is asking for trouble, but 20 characters is simply not enough for users doing research on our 1.5 sites.
My tech support is now available in over thirty shades of green!

wroken
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed May 13, 2009 5:33 pm

Re: How to override the searchword limit to be able to searc

Post by wroken » Tue Mar 01, 2011 7:40 pm

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.


Fuente: http://www.enzolina.com/web/joomla-chan ... -limit-20/

cas4
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Tue Jun 14, 2011 12:38 am

Re: How to override the searchword limit to be able to searc

Post by cas4 » Tue Jun 21, 2011 4:57 am

Does anyone have a fix for Joomla 1.6?

russellwharvey
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Jun 29, 2011 9:40 am

Re: How to override the searchword limit to be able to searc

Post by russellwharvey » Wed Jun 29, 2011 9:51 am

For Joomla 1.6:

Files: /language/en-GB/en-GB.localise.php, /administrator/en-GB/en-GB.localise.php

To lower the minimum character limit, find the following bit of code in each file.

Code: Select all

public static function getLowerLimitSearchWord() {
   return 3;
}
Change the return value to a new lower limit. For example, 1.

Code: Select all

public static function getLowerLimitSearchWord() {
   // return 3;
  return 1;
}
To raise the maximum character limit, find the following bit of code in each file.

Code: Select all

public static function getUpperLimitSearchWord() {
   return 20;
}
Change the return value to a new upper limit. For example, 50.

Code: Select all

public static function getUpperLimitSearchWord() {
   // return 20;
  return 50;
}

atpatil11
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Mon Mar 14, 2011 1:25 pm

Re: How to override the searchword limit to be able to searc

Post by atpatil11 » Mon Mar 05, 2012 6:08 am

Hi Russellwharvey,
I did what you said for Joomla 1.7 but its not working. Any luck for Joomla 1.7?
Thank You.


Locked

Return to “Joomla! 1.5 Coding”