2015-01-23, 08:03 PM
2015-01-23, 08:06 PM
I will send you a last version with a text area for input which can also be extended manually.
Coming in a few minutes.
Last version with text box:
Have a nice time!!
Coming in a few minutes.
Last version with text box:
<?php
/**
* Disallow direct access to this file for security reasons
*
*/
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("search_do_search_start", "search_exact");
/**
* Standard MyBB info function
*
*/
function search_exact_info()
{
global $lang;
return Array(
'name' => "search_exact",
'description' => "search with keywords placed within quotes (exact search)",
'website' => '',
'author' => 'Ad Bakker',
'authorsite' => '',
'version' => '1.0',
'guid' => '',
'compatibility' => '18*',
);
}
function search_exact_activate()
{
require_once(MYBB_ROOT . '/inc/adminfunctions_templates.php');
find_replace_templatesets('search', '#' . preg_quote('<input type="text" class="textbox" name="keywords" size="35" maxlength="250" />') . '#','<textarea name="keywords" cols="60" rows="10"></textarea>');
}
function search_exact_deactivate()
{
require_once(MYBB_ROOT . '/inc/adminfunctions_templates.php');
find_replace_templatesets('search', '#' . preg_quote('<textarea name="keywords" cols="60" rows="10"></textarea>') . '#','<input type="text" class="textbox" name="keywords" size="35" maxlength="250" />');
}
function search_exact()
{
global $mybb, $templates;
$mybb->input['keywords'] = "\"{$mybb->input['keywords']}\"";
}
?>
Have a nice time!!
2015-01-23, 08:25 PM
Wow it looks great! You're awesome!
2015-01-25, 03:06 AM
Exact search as the default wasn't working for the search thread option at the bottom of threads, so I messaged Ad Bakker and he made it work.
He said to add
right below
and that will make it work.
So the new full code will look like this:
He said to add
$plugins->add_hook("search_thread_start", "search_exact");
right below
$plugins->add_hook("search_do_search_start", "search_exact");
and that will make it work.
So the new full code will look like this:
<?php
/**
* Disallow direct access to this file for security reasons
*
*/
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("search_do_search_start", "search_exact");
$plugins->add_hook("search_thread_start", "search_exact");
/**
* Standard MyBB info function
*
*/
function search_exact_info()
{
global $lang;
return Array(
'name' => "search_exact",
'description' => "search with keywords placed within quotes (exact search)",
'website' => '',
'author' => 'Ad Bakker',
'authorsite' => '',
'version' => '1.0',
'guid' => '',
'compatibility' => '18*',
);
}
function search_exact()
{
global $mybb;
$mybb->input['keywords'] = "\"{$mybb->input['keywords']}\"";
}
?>