Search 如何将ft_min_word_len=4修改为ft_min_word_len=1,以便osclass 3.7.1可以搜索至少1个字符的单词,而不是4个?

Search 如何将ft_min_word_len=4修改为ft_min_word_len=1,以便osclass 3.7.1可以搜索至少1个字符的单词,而不是4个?,search,osclass,Search,Osclass,我想将搜索的最小字符长度从4更改为1 我找到了关于osclass的文档 问题是,从我在主机上使用的数据库来看,只有这一个有4个字符的限制,其余的都有0或未设置 所以我只需要在osclass数据库中将这个ft\u min\u word\u len=4修改为'ft\u min\u word\u len=1' 有人能帮忙解决吗?我有权访问cpanel和phpMyAdmin。事实证明,从我的脚本来看,只有osclass使用服务器上的ft_min_word_len=4变量 因此,我无法更改它,因为我有一个

我想将搜索的最小字符长度从4更改为1

我找到了关于osclass的文档

问题是,从我在主机上使用的数据库来看,只有这一个有4个字符的限制,其余的都有0或未设置

所以我只需要在osclass数据库中将这个
ft\u min\u word\u len=4
修改为'ft\u min\u word\u len=1'


有人能帮忙解决吗?我有权访问cpanel和phpMyAdmin。事实证明,从我的脚本来看,只有osclass使用服务器上的ft_min_word_len=4变量


因此,我无法更改它,因为我有一个共享服务器主机,提供商也不会因此更改它。

结果表明,有另一种方法可以避免更改此变量

我在这里写这个答案是因为如果没有其他人在论坛(或论坛)上分享信息的帮助,我自己也无法找到答案

接下来是两天的工作:

ideea是在将项目添加到数据库之前过滤项目的标题和说明。此筛选器必须为少于4个字母的单词中缺少的每个字母添加“\u1”。 例如: e___ 前__ 埃克萨_

为此,我们需要两个函数: addunderline($t)和removeunderline($t)

ideea将标题、描述和搜索模式中少于4个字符的所有单词转换为使用下划线字符的最少4个字符的单词

所以,在数据库中会有“e_uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu。 然后,当显示信息时,我们使用removeunderline函数

请在开始之前备份您的文件

遵循以下步骤

对于Osclass 3.7.1和Bender主题:

在复制粘贴代码之前,请停止并分析代码。我是一个人,错误可能会发生,因为我在多次修改后做了以下说明

一,。 /oc content/themes/bender/item-post.php

替换

 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 osc_item_title()
 if(osc_count_items() == 0) {?>
 <p class="empty" ><?php printf(__('There are no results matching "%s"', 'bender'), osc_search_pattern()) ; ?></p>
 <input class="input-text" type="text" name="sPattern"  id="query" value="<?php echo osc_esc_html(osc_search_pattern()); ?>" />
 $p_sPattern   = trim(strip_tags(Params::getParam('sPattern')));
 $pattern    = osc_search_pattern();
 osc_item_title()
 <title><?php echo meta_title() ; ?></title>
 osc_item_title()
 osc_premium_description()
 /**
 * Gets title from current item, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_item_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_item_field("s_title", $locale);
    if($title=='') {
        $title = osc_item_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_item_field("s_title", @$locale['pk_c_code']);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }
 /**
 * Gets title from current premium, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_premium_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_premium_field("s_title", $locale);
    if($title=='') {
        $title = osc_premium_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_premium_field("s_title", $locale);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }

四,。 /oc content/themes/bender/search.php

替换

 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 osc_item_title()
 if(osc_count_items() == 0) {?>
 <p class="empty" ><?php printf(__('There are no results matching "%s"', 'bender'), osc_search_pattern()) ; ?></p>
 <input class="input-text" type="text" name="sPattern"  id="query" value="<?php echo osc_esc_html(osc_search_pattern()); ?>" />
 $p_sPattern   = trim(strip_tags(Params::getParam('sPattern')));
 $pattern    = osc_search_pattern();
 osc_item_title()
 <title><?php echo meta_title() ; ?></title>
 osc_item_title()
 osc_premium_description()
 /**
 * Gets title from current item, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_item_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_item_field("s_title", $locale);
    if($title=='') {
        $title = osc_item_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_item_field("s_title", @$locale['pk_c_code']);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }
 /**
 * Gets title from current premium, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_premium_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_premium_field("s_title", $locale);
    if($title=='') {
        $title = osc_premium_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_premium_field("s_title", $locale);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }
添加以下内容:

    /**
     * transforms all words with under 4 characters to 4 characters ones
     *
     * @return string
     */

 function addunderline($t)
 {
 if(count($t))
 {
  $words = explode(" ", $t);
  for ($i=0; $i<count($words); $i++)
  { $ln=strlen($words[$i]);
  if($ln==1)  $words[$i]=$words[$i].='___';
  if($ln==2)  $words[$i]=$words[$i].='__';
  if($ln==3)  $words[$i]=$words[$i].='_';
  }
  return implode(" ", $words);
 }
 else { return $t;
      }
 }

    /**
     * Removes '_' from the end of the 4 characters words
     *
     * @return string
     */
 function removeunderline($t)
 {
 if(count($t))
 {
  $words = explode(" ", $t);
  for ($i=0; $i<count($words); $i++)
  { 
    if(strlen($words[$i])==4)  $words[$i]=chop($words[$i],"_");

  }
  return implode(" ", $words);
 }
 else { return $t;
      }
 }

八,。 /oc content/themes/bender/functions.php

添加到文件末尾(不要在文件末尾留下空行)

如果从第13点开始进行修改,则无需进行这些更改[以下带有osc_item_title()的更改]

诸如此类

 osc_premium_title()

十,。 /oc content/themes/bender/common/head.php

替换

 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 osc_item_title()
 if(osc_count_items() == 0) {?>
 <p class="empty" ><?php printf(__('There are no results matching "%s"', 'bender'), osc_search_pattern()) ; ?></p>
 <input class="input-text" type="text" name="sPattern"  id="query" value="<?php echo osc_esc_html(osc_search_pattern()); ?>" />
 $p_sPattern   = trim(strip_tags(Params::getParam('sPattern')));
 $pattern    = osc_search_pattern();
 osc_item_title()
 <title><?php echo meta_title() ; ?></title>
 osc_item_title()
 osc_premium_description()
 /**
 * Gets title from current item, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_item_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_item_field("s_title", $locale);
    if($title=='') {
        $title = osc_item_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_item_field("s_title", @$locale['pk_c_code']);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }
 /**
 * Gets title from current premium, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_premium_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_premium_field("s_title", $locale);
    if($title=='') {
        $title = osc_premium_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_premium_field("s_title", $locale);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }

12.如果从第14点开始进行修改,则无需进行这些更改

/oc content/themes/bender/loop-single-premium.php

替换

 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 osc_item_title()
 if(osc_count_items() == 0) {?>
 <p class="empty" ><?php printf(__('There are no results matching "%s"', 'bender'), osc_search_pattern()) ; ?></p>
 <input class="input-text" type="text" name="sPattern"  id="query" value="<?php echo osc_esc_html(osc_search_pattern()); ?>" />
 $p_sPattern   = trim(strip_tags(Params::getParam('sPattern')));
 $pattern    = osc_search_pattern();
 osc_item_title()
 <title><?php echo meta_title() ; ?></title>
 osc_item_title()
 osc_premium_description()
 /**
 * Gets title from current item, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_item_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_item_field("s_title", $locale);
    if($title=='') {
        $title = osc_item_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_item_field("s_title", @$locale['pk_c_code']);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }
 /**
 * Gets title from current premium, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_premium_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_premium_field("s_title", $locale);
    if($title=='') {
        $title = osc_premium_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_premium_field("s_title", $locale);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }

诸如此类

 osc_premium_title()

十三,。 /oc包括/osclass/helpers/hItems.php

替换

 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 osc_item_title()
 if(osc_count_items() == 0) {?>
 <p class="empty" ><?php printf(__('There are no results matching "%s"', 'bender'), osc_search_pattern()) ; ?></p>
 <input class="input-text" type="text" name="sPattern"  id="query" value="<?php echo osc_esc_html(osc_search_pattern()); ?>" />
 $p_sPattern   = trim(strip_tags(Params::getParam('sPattern')));
 $pattern    = osc_search_pattern();
 osc_item_title()
 <title><?php echo meta_title() ; ?></title>
 osc_item_title()
 osc_premium_description()
 /**
 * Gets title from current item, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_item_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_item_field("s_title", $locale);
    if($title=='') {
        $title = osc_item_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_item_field("s_title", @$locale['pk_c_code']);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }
 /**
 * Gets title from current premium, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_premium_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_premium_field("s_title", $locale);
    if($title=='') {
        $title = osc_premium_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_premium_field("s_title", $locale);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }

十四,。 /oc包括/osclass/helpers/hPremium.php

替换

 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 <?php ItemForm::title_input('title',osc_current_user_locale(), osc_esc_html( bender_item_title() )); ?>
 osc_item_title()
 if(osc_count_items() == 0) {?>
 <p class="empty" ><?php printf(__('There are no results matching "%s"', 'bender'), osc_search_pattern()) ; ?></p>
 <input class="input-text" type="text" name="sPattern"  id="query" value="<?php echo osc_esc_html(osc_search_pattern()); ?>" />
 $p_sPattern   = trim(strip_tags(Params::getParam('sPattern')));
 $pattern    = osc_search_pattern();
 osc_item_title()
 <title><?php echo meta_title() ; ?></title>
 osc_item_title()
 osc_premium_description()
 /**
 * Gets title from current item, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_item_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_item_field("s_title", $locale);
    if($title=='') {
        $title = osc_item_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_item_field("s_title", @$locale['pk_c_code']);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }
 /**
 * Gets title from current premium, if $locale is unspecified $locale is current user locale
 *
 * @param string $locale
 * @return string
 */
 function osc_premium_title($locale = "") {
    if ($locale == "") $locale = osc_current_user_locale();
    $title = osc_premium_field("s_title", $locale);
    if($title=='') {
        $title = osc_premium_field("s_title", osc_language());
        if($title=='') {
            $aLocales = osc_get_locales();
            foreach($aLocales as $locale) {
                $title = osc_premium_field("s_title", $locale);
                if($title!='') {
                    break;
                }
            }
        }
    }
    return (string) $title;
 }

结束

现在,您必须编辑并保存网站上的所有列表,或者等待所有列表由其自动编辑并保存。(或者在DB中重新生成全文搜索表-您可以在线找到有关该列表的详细信息)

Obs。 这使得: -URL、项目标题和项目描述在自动生成的电子邮件中保留下划线, -URL在seo友好的URL中保留下划线 -项目标题和项目描述在osclass管理员区域中保留下划线(仅适用于管理员,不适用于已登录用户)。 -像bmw x5这样的单词在数据库中变成了bmw_x5,uu,因此您需要进行修改以添加和删除下划线函数来解决标点问题,而不使用正则表达式中的字符,因为osclass将它们转换为;如果项目被编辑并保存,这些字符将与每个编辑保存操作相乘。我用obs解决了这个问题。允许用户不使用字符

编辑

项目链接的解析方式如下:

/oc包括/osclass/helpers/hDefines.php

而不是

 $url = str_replace('{ITEM_TITLE}', osc_sanitizeString($item['s_title']), $url);
对于{ITEM_TITLE}和{ITEM_DESCRIPTION}:

/oc includes/osclass/emails.php

将removeunderline()置于{ITEM_TITLE}和{ITEM_DESCRIPTION}值处

例如:

 $words   = array();
    $words[] = array(
        '{ITEM_DESCRIPTION_ALL_LANGUAGES}',
        '{ITEM_DESCRIPTION}',
        '{ITEM_COUNTRY}',
        '{ITEM_PRICE}',
        '{ITEM_REGION}',
        '{ITEM_CITY}',
        '{ITEM_ID}',
        '{USER_NAME}',
        '{USER_EMAIL}',
        '{ITEM_TITLE}',
        '{ITEM_URL}',
        '{ITEM_LINK}',
        '{VALIDATION_LINK}',
        '{VALIDATION_URL}',
        '{EDIT_LINK}',
        '{EDIT_URL}',
        '{DELETE_LINK}',
        '{DELETE_URL}'
    );
    $words[] = array(
        $all,
        removeunderline($item['s_description']), // here
        $item['s_country'],
        osc_format_price($item['i_price']),
        $item['s_region'],
        $item['s_city'],
        $item['pk_i_id'],
        $item['s_contact_name'],
        $item['s_contact_email'],
        removeunderline($item['s_title']), // here
        $item_url,
        $item_link,
        '<a href="' . $validation_url . '" >' . $validation_url . '</a>',
        $validation_url,
        '<a href="' . $edit_url . '">' . $edit_url . '</a>',
        $edit_url,
        '<a href="' . $delete_url . '">' . $delete_url . '</a>',
        $delete_url
    );
$words=array();
$words[]=数组(
“{ITEM_DESCRIPTION_ALL_LANGUAGES}”,
“{ITEM_DESCRIPTION}”,
“{ITEM_COUNTRY}”,
“{ITEM_PRICE}”,
“{ITEM_REGION}”,
“{ITEM_CITY}”,
“{ITEM_ID}”,
“{USER_NAME}”,
“{USER_EMAIL}”,
“{ITEM_TITLE}”,
“{ITEM_URL}”,
“{ITEM_LINK}”,
“{VALIDATION_LINK}”,
“{VALIDATION_URL}”,
“{EDIT_LINK}”,
“{EDIT_URL}”,
“{删除链接}”,
“{DELETE_URL}”
);
$words[]=数组(
$all,
removeunderline($item['s_description']),//此处
$item['s_country'],
osc格式价格($item['i_price']),
$item['s_region'],
$item['s_city'],
$item['pk_i_id'],
$item['s_contact_name'],
$item['s_contact_email'],
移除下划线($item['s_title']),//此处
$item_url,
$item_link,
'',
$validation\u url,
'',
$edit_url,
'',
$delete\u url
);
对该文件中的所有{ITEM_TITLE}执行相同的操作(10次替换)

对该文件中的所有{ITEM_DESCRIPTION}执行相同的操作(3次替换)