在用joomla完成项目的时候,需要使用搜索功能,但当我使用两个词的时候系统就会提示“”搜索关键字最少不能少于 3 个字符,最多不能超过 200 个字符.“。那么如何修改这个限制呢

要求

搜索关键字最少不能少于 3 个字符,最多不能超过 200 个字符.

如何来做?

通过代码调试追踪,发现实际上控制这个的关键是在语言文件中。我们需要给自己的语言文件创建一个localise.php。(在j5之前需要使用zh-CN.localise.php这个文件名)

在语言文件中创建localise.php文件。比如我使用的是简体中文。因此,我需要去到网站前台\language\zh-CN目录下新建localise.php。内容如下:

<?php
/**
 * @package    Joomla.Language
 *
 * @copyright  Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('_JEXEC') or die;

/**
 * zh-CN localise class.
 *
 * @since  1.6
 */
abstract class Zh_CNLocalise
{
	/**
	 * Returns the potential suffixes for a specific number of items
	 *
	 * @param   integer  $count  The number of items.
	 *
	 * @return  array  An array of potential suffixes.
	 *
	 * @since   1.6
	 */
	public static function getPluralSuffixes($count)
	{
		if ($count == 0)
		{
			return array('0');
		}
		elseif ($count == 1)
		{
			return array('1');
		}
		else
		{
			return array('MORE');
		}
	}

	/**
	 * Returns the ignored search words
	 *
	 * @return  array  An array of ignored search words.
	 *
	 * @since   1.6
	 */
	public static function getIgnoredSearchWords()
	{
		return array('啊', '呢', '嘛');
	}

	/**
	 * Returns the lower length limit of search words
	 *
	 * @return  integer  The lower length limit of search words.
	 *
	 * @since   1.6
	 */
	public static function getLowerLimitSearchWord()
	{
		return 2;
	}

	/**
	 * Returns the upper length limit of search words
	 *
	 * @return  integer  The upper length limit of search words.
	 *
	 * @since   1.6
	 */
	public static function getUpperLimitSearchWord()
	{
		return 20;
	}

	/**
	 * Returns the number of chars to display when searching
	 *
	 * @return  integer  The number of chars to display when searching.
	 *
	 * @since   1.6
	 */
	public static function getSearchDisplayedCharactersNumber()
	{
		return 200;
	}
}

 

 

作者: 樱木花道

Joomla程序员,从J1.5到J4.x始终都在做Joomla相关开发定制工作,有超过10年行业经验,国内Joomla扩展开发商ZMAX团队的核心成员

作者网站:ZMAX程序人

评论 (0)

  • 最新在前
  • 最佳在前