Help Center

Powered by Minitek FAQ Book
Loading...

I want ban some words

X
xavierPosted 8 years agoEdited 8 years ago
 I would like banish the following words from the search :
- Comment
- à
- un

Indeed, these words prevent a good search for questions.

I want to keep the option "any words"


Thank you in advance for your help,

Best regards,
Xavier
Loading...
0
#1979

7 answers

M
MinitekPosted 8 years agoModerator
Hi Xavier,

There is no way to ban words in current version.
You can add this as a feature request at:
https://www.minitek.gr/support/feature-requests
X
xavierPosted 8 years ago
Hi Yannis,

Thank you for your reply.

but.. i see that in the code ("search.php") :
"// Check for words to ignore.
$aterms = explode(' ', JString::strtolower($searchword));"

Is it possible to insert words here?
M
MinitekPosted 8 years agoModerator
Hi Xavier,

In which file exactly?
X
xavierPosted 8 years ago
Hi Yannis,

Sorry..

In fpbutilities.php at line number : 129

	// Filter by search word
		if (array_key_exists('fbp_questions_page_limit', $faqbookpro_type)) 
		{ 
			// Component
			$phrase = isset($faqbookpro_type['fbp_questions_c_search_for']) ? $faqbookpro_type['fbp_questions_c_search_for'] : 'all';
			
			switch ($phrase)
			{
				case 'exact':
					$text = $db->quote('%' . $db->escape($word, true) . '%', false);
					$wheres2 = array();
					if ($faqbookpro_type['fbp_questions_c_search_in_title']) 
					{
						$wheres2[] = 'a.title LIKE ' . $text;
					}
					if ($faqbookpro_type['fbp_questions_c_search_in_introtext']) 
					{
						$wheres2[] = 'a.introtext LIKE ' . $text;
					}
					if ($faqbookpro_type['fbp_questions_c_search_in_fulltext']) 
					{
						$wheres2[] = 'a.fulltext LIKE ' . $text;
					}
					$where = '(' . implode(') OR (', $wheres2) . ')';
					$query->where($where);
					break;
	
				case 'all':
				case 'any':
				default:
					$words = explode(' ', $word);
					$wheres = array();
	
					foreach ($words as $word)
					{
						$word = $db->quote('%' . $db->escape($word, true) . '%', false);
						$wheres2 = array();
						if ($faqbookpro_type['fbp_questions_c_search_in_title']) 
						{
							$wheres2[] = 'LOWER(a.title) LIKE LOWER(' . $word . ')';
						}
						if ($faqbookpro_type['fbp_questions_c_search_in_introtext']) 
						{
							$wheres2[] = 'LOWER(a.introtext) LIKE LOWER(' . $word . ')';
						}
						if ($faqbookpro_type['fbp_questions_c_search_in_fulltext']) 
						{
							$wheres2[] = 'LOWER(a.fulltext) LIKE LOWER(' . $word . ')';
						}
						$wheres[] = implode(' OR ', $wheres2);
					}
	
					$where = '(' . implode(($phrase == 'all' ? ') AND (' : ') OR ('), $wheres) . ')';
					$query->where($where);
					break;
			}
		} 
		else 
		{ 
M
MinitekPosted 8 years agoModerator
Try this:

Before line:
foreach ($words as $word)
{

add:
$badwords = array('word1', 'word2', 'word3'); // This is an array that contains all excluded words


After line:
foreach ($words as $word)
{

add:
if (in_array($word, $badwords)) { continue; }



Please note that this code is provided without support and you will have to debug any possible problems by yourself.
X
xavierPosted 8 years ago
Hi Yannis,

Sorry for the delay .. It's work, thank you very much !!

Is it possible to change the code also for this topic : https://www.minitek.gr/support/feature-requests/8-minitek-live-search/134-how-to-add-sections-in-results-link-description ?

There will be no updates

Thank you very much again.

Bes regards,
M
MinitekPosted 8 years agoModerator
Hi Xavier,

No I am afraid this is not possible at the moment as it would require many code changes in many files.