Joomla! com_search glitch
Tags: joomla, com_search
Let’s come on a site joomla.org and click on the Search menu item. Now we enter text “test test” for search (with three spaces between words!). As a result of the search the huge document with a lot of “<span class=”highlight”></span>” is received.
To get rid of this glitch, it is necessary in a file /components/com_search/search.php after a line
$searchword = strval( mosGetParam( $_REQUEST, 'searchword', '' ) );
(or, in older versions
$searchword = $database->getEscaped( trim( $searchword ) );
) add
$searchword = preg_replace( '/\s{2,}/s', ' ', $searchword );
It will allow to remove a series of spaces from the search query.
PS. Firstly I have found the description of this glitch and a method of solution at russian forum joomlaforum.ru.
June 1st, 2007 at 3:59 am
Now THAT works great - thanks!!
October 29th, 2007 at 3:32 pm
Here is another good (not sure if better) solution but clear for PHP new bies like me.
Open file components/com_search/search.php find this line of code:
$searchword = strval( mosGetParam( $_REQUEST, ’searchword’, ” ) );
Add these lines:
//Remove many redundant spaces - hacker :))
$searchword_array = explode(” “, $searchword);
$searchword = “”;
for($i=0;$i
October 29th, 2007 at 4:14 pm
I conjecture what you mean, but I think preg_replace works faster then explode and following concatenation.
December 23rd, 2007 at 2:17 am
Hi there and thanks for the tutorials they actually worked now I had a question for you :
I would like to give my users the ability to search the database and instead displaying the link as a text is it possible to have displayed picture instead as a link .
The other question I had was I like to display three drop down select lists on the front page so for example one of them would have Car Names listed the otherone would have Car Model listings and the third one would have Car Color now my question is how can I make it work so that if one of my users selects :BMW car—>320–>RED it would show only that type of Car and not all types of cars that I have stored in my database and again no text as a link but Picture of that car .
Thank you for your help in this matter!
Bahri Bare
December 24th, 2007 at 9:29 am
Bahri Bare:
The most convenient way to solve this problem is creation of own search component which will display images in results. However, if you will not use the built in search for other purposes, it is possible to unpublish all search mambots and to write the mambot, which will display images.
In this case, it is really easier to write the component. Thus, it is possible to use any way of creation of "dependent" lists (including AJAX).
December 28th, 2007 at 7:28 am
Hi!
Just wanted to give thanks for this fix.