Reduce minimum search size Topic is solved

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
tezzerp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Mon Aug 20, 2018 1:48 pm

Reduce minimum search size

Post by tezzerp » Sat Jan 12, 2019 9:13 am

Hello all
I know this is a weird one , but currently the default search module needs a minimum of 3 letters. Our site is a car club and a lot of the car models are 2 letters.
Is there a way to reduce this minimum to 2?
I have tried Smart Search and that doesn't really work for us
Thanks

Terry

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2863
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Reduce minimum search size

Post by SharkyKZ » Sat Jan 12, 2019 10:14 am

It's defined in language pack but can be overridden with a system plugin.

Code: Select all

defined('_JEXEC') or die;

use Joomla\CMS\Plugin\CMSPlugin;

class PlgSystemExample extends CMSPlugin
{
	protected $app;

	public function onAfterInitialise()
	{
		$this->app->getLanguage()->setLowerLimitSearchWordCallback(array($this, 'setLowerLimitSearchWord'));	
	}

	public static function setLowerLimitSearchWord()
	{
		return 2;
	}
}
https://docs.joomla.org/J3.x:Creating_a ... for_Joomla

tezzerp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Mon Aug 20, 2018 1:48 pm

Re: Reduce minimum search size

Post by tezzerp » Sat Jan 12, 2019 12:27 pm

I am really sorry but I am completely lost.
Can I overide the language pack?
Thanks
Terry

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2863
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Reduce minimum search size

Post by SharkyKZ » Sat Jan 12, 2019 3:48 pm

If you edit language pack files, your changes will be lost when updating Joomla! (if you use en-GB language) or when updating language pack (if you use any other language).

Plugin method doesn't have this issue.

tezzerp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Mon Aug 20, 2018 1:48 pm

Re: Reduce minimum search size

Post by tezzerp » Sun Jan 13, 2019 1:38 pm

Thanks, will try and figure it out
Cheers
Terry

User avatar
leolam
Joomla! Master
Joomla! Master
Posts: 20651
Joined: Mon Aug 29, 2005 10:17 am
Location: Netherlands/ Germany/ S'pore/Bogor/ North America
Contact:

Re: Reduce minimum search size

Post by leolam » Sun Jan 13, 2019 3:01 pm

SharkyKZ wrote:
Sat Jan 12, 2019 3:48 pm
If you edit language pack files, your changes will be lost when updating Joomla! (if you use en-GB language) or when updating language pack (if you use any other language).
Sorry but that is only partly correct. Language overrides are a basic functionality with languages and they are not replaced with an update

Leo 8)
Joomla's #1 Professional Services Provider:
#Joomla Professional Support: https://gws-desk.com -
#Joomla Specialized Hosting Solutions: https://gws-host.com -

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2863
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Reduce minimum search size

Post by SharkyKZ » Sun Jan 13, 2019 4:21 pm

leolam wrote:
Sun Jan 13, 2019 3:01 pm
SharkyKZ wrote:
Sat Jan 12, 2019 3:48 pm
If you edit language pack files, your changes will be lost when updating Joomla! (if you use en-GB language) or when updating language pack (if you use any other language).
Sorry but that is only partly correct. Language overrides are a basic functionality with languages and they are not replaced with an update

Leo 8)
This concerns xx-XX.localise.php file, not language overrides.

tezzerp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Mon Aug 20, 2018 1:48 pm

Re: Reduce minimum search size

Post by tezzerp » Mon Jan 14, 2019 10:32 am

I am really sorry but I cannot figure out how to create a system plugin?

Could I do it by copying a file in Cpanel file manager then renaming and changing the content to as above?
Sorry to be a bit of a numpty!
Thanks
Terry

KianWilliam
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Thu Jan 12, 2017 10:13 am

Re: Reduce minimum search size

Post by KianWilliam » Tue Jan 15, 2019 7:26 am

This tutorial could give you a total vision of how to create a plugin in joomla:
https://docs.joomla.org/J3.x:Creating_a ... for_Joomla
Kian William

tezzerp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Mon Aug 20, 2018 1:48 pm

Re: Reduce minimum search size

Post by tezzerp » Tue Jan 15, 2019 9:52 am

Thanks I must be thick , I made the plugin in the three parts, zipped and installed. It seems to install correctly. When I enabled in plugins, it put some text from the code at the top of the page????
I have now disabled it again.
Any ideas
Thanks
Last edited by tezzerp on Tue Jan 15, 2019 10:07 am, edited 1 time in total.

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17350
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Reduce minimum search size

Post by toivo » Tue Jan 15, 2019 10:02 am

Add a line starting with the characters <?php to the beginning of the PHP file.

Compress a zip folder containing the PHP file with the code, posted by @SharkyKZ, and the XML file, the manifest file that you need to create.
Toivo Talikka, Global Moderator

tezzerp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Mon Aug 20, 2018 1:48 pm

Re: Reduce minimum search size

Post by tezzerp » Tue Jan 15, 2019 10:18 am

Thanks, now done that and it installed and looks OK, no funny text
But It doesn't work :-(
Is the code above correct?

Thanks
Terry

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17350
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Reduce minimum search size

Post by toivo » Tue Jan 15, 2019 10:46 am

Did you enable the new plugin?
Toivo Talikka, Global Moderator

tezzerp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Mon Aug 20, 2018 1:48 pm

Re: Reduce minimum search size

Post by tezzerp » Tue Jan 15, 2019 10:50 am

Yes, managed to figure it out. I cobbled together the manifest file and didn't realise the difference between content and system. Now installed and working :-)
One question , how do I delete the old version?
Thanks
Terry

tezzerp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Mon Aug 20, 2018 1:48 pm

Re: Reduce minimum search size

Post by tezzerp » Tue Jan 15, 2019 10:55 am

Sorted, deleted it now.
Thanks to everyone for your help. I have now created my own plugin
Now to market it ......... :-)
Terry

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17350
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Reduce minimum search size

Post by toivo » Tue Jan 15, 2019 11:14 am

Good to hear. The plugin created by @SharkyKZ is simple but effective.

You could add an option to your plugin to let the administrator select the minimum length of the search word.
Toivo Talikka, Global Moderator

tezzerp
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 130
Joined: Mon Aug 20, 2018 1:48 pm

Re: Reduce minimum search size

Post by tezzerp » Tue Jan 15, 2019 11:22 am

OK how would I do that? :-)

Thanks
Terry

KianWilliam
Joomla! Guru
Joomla! Guru
Posts: 561
Joined: Thu Jan 12, 2017 10:13 am

Re: Reduce minimum search size

Post by KianWilliam » Thu Jan 17, 2019 4:59 am

In manifest file(plugin .xml)file, under <config> and <fields name='params'> tags consider a jformfield of text type with name, .... and then employ it in plugin php file, study the tutorial, it is not difficult.
Kian William


Locked

Return to “General Questions/New to Joomla! 3.x”