Skip to content

Commit

Permalink
Added option to General>search to limit small individual words form b…
Browse files Browse the repository at this point in the history
…eing searched - ADDED
  • Loading branch information
Stiofan committed Jun 18, 2015
1 parent b6fd64b commit 8eeaec9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions change_log.txt
Expand Up @@ -11,6 +11,7 @@ Cyrillic characters not exporting correctly in import/export - FIXED
With WPML search results listings for all languages - FIXED
In registration send password to email note removed when user allowed choose own password - FIXED
Menu save triggering rebuilding of category count and review counts - FIXED
Added option to General>search to limit small individual words form being searched - ADDED

v1.4.8
Send Enquiry & send to friend options removed from listings page - CHANGED
Expand Down
15 changes: 15 additions & 0 deletions geodirectory-admin/option-pages/general_settings_array.php
Expand Up @@ -289,6 +289,21 @@
'css' => 'min-width:300px;',
'std' => ''
),
array(
'name' => __('Individual word search limit', GEODIRECTORY_TEXTDOMAIN),
'desc' => __('With this option you can limit individual words being searched for, for example searching for `Jo Brown` would return results with words like `Jones`, you can exclude these types of small character words if you wish.', GEODIRECTORY_TEXTDOMAIN),
'id' => 'geodir_search_word_limit',
'css' => 'min-width:300px;',
'std' => 'gridview_onehalf',
'type' => 'select',
'class' => 'chosen_select',
'options' => array_unique(array(
'0' => __('Disabled', GEODIRECTORY_TEXTDOMAIN),
'1' => __('1 Character words excluded', GEODIRECTORY_TEXTDOMAIN),
'2' => __('2 Character words and less excluded', GEODIRECTORY_TEXTDOMAIN),
'3' => __('3 Character words and less excluded', GEODIRECTORY_TEXTDOMAIN),
))
),


array('type' => 'sectionend', 'id' => 'search_settings'),
Expand Down
25 changes: 25 additions & 0 deletions geodirectory-functions/listing_filters.php
Expand Up @@ -369,6 +369,16 @@ function geodir_posts_fields($fields)
global $s;
if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
$keywords = explode(" ", $s);

if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
foreach($keywords as $kkey=>$kword){
if(strlen($kword)<=$klimit){
unset($keywords[$kkey]);
}
}
}


if (count($keywords) > 1) {
$parts = array(
'AND' => 'gd_alltitlematch_part',
Expand Down Expand Up @@ -548,6 +558,13 @@ function geodir_posts_orderby($orderby)

if (is_search() && isset($_REQUEST['geodir_search']) && $s && trim($s) != '') {
$keywords = explode(" ", $s);
if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
foreach($keywords as $kkey=>$kword){
if(strlen($kword)<=$klimit){
unset($keywords[$kkey]);
}
}
}
if ($sort_by == 'nearest' || $sort_by == 'farthest') {
if (count($keywords) > 1) {
$orderby = $orderby . " ( gd_titlematch * 2 + gd_featured * 5 + gd_exacttitle * 10 + gd_alltitlematch_part * 100 + gd_titlematch_part * 50 + gd_content * 1.5) DESC, ";
Expand Down Expand Up @@ -836,6 +853,14 @@ function searching_filter_where($where)

if ($s != '') {
$keywords = explode(" ", $s);
if(is_array($keywords) && $klimit = get_option('geodir_search_word_limit')){
foreach($keywords as $kkey=>$kword){
if(strlen($kword)<=$klimit){
unset($keywords[$kkey]);
}
}
}

if (!empty($keywords)) {
foreach ($keywords as $keyword) {
$keyword = trim($keyword);
Expand Down

0 comments on commit 8eeaec9

Please sign in to comment.