< 返回 1.2 Joomla如何修改搜索关键字最少不能少于 3 个字符的限制 - 博客

在用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;
	}
}

 

 

博客

第1章:经验分享
第2章:专题教程
第3章:扩展推荐
第13章:扩展更新日志
  • 内容提要
  • 留言讨论 (0)
  • 视频教程
在用joomla完成项目的时候,需要使用搜索功能,但当我使用两个词的时候系统就会提示“”搜索关键字最少不能少于 3 个字符,最多不能超过 200 个字符.“。那么如何修改这个限制呢

评论 (0)

  • 最新在前
  • 最佳在前

内容待完善

该课程提供视频版,可以观看完整的视频教程