MyBB Community Forums

Full Version: Search feature enhancement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
myBB version :
1.8.19

Issue :
search.php - limited usability, due to required input of keyword or author fields.

Details :
Currently user is forced to input a keyword or author to perform search, or else search will not be executed. This limits search feature to only these 2 options and not allow to use additional search options that are present in form alone without providing keyword and author, that could allow to search for new posts, old posts, posts without reply and many other combinations where a keyword and author have no meaning.

For example, with current options, one could search for "posts from last week that have not less than 10 replies", but one cant, since keyword and author has not been provided. - Note that for this criteria, keyword and author have no meaning.

Solution :
allow empty keyword and author input, so the search options like show posts with X replies, or show posts not older than 1 week and other combinations of search options, become search criteria.
I actually believe this has been a MyBB issue forever. I've never not been able to search without something there.

I did at one point end up editing inc --> functions_search.php to comment out a chunk of code so my users could search by x thread prefix only (rpg forum, so searching for threads with open thread prefix was cool).

You can just simply go to the file i mentioned above, find
if(!$keywords && !$search['author'])
	{
		error($lang->error_nosearchterms);
	}
And then comment it out like so
// if(!$keywords && !$search['author'])
	// {
	// 	error($lang->error_nosearchterms);
	// }
indeed, removing just this one line, unlocks searching to whole new level.
and then if we could add "by replies count" and "by views count" to sort options, it could be complete.

It turned out to be nice search feature enhancement, i changed topic title to reflect this proposal.

what do myBB team thinks about it ?
I agree it makes no sense to require either of those fields, I'm not sure why it was ever written that way at all. Additional sorting options might be nice, especially for replies count - views count I wouldn't find too useful personally but I don't have anything against it.
Good find! Would be really nice to change it Smile Feel free to open a PR @avril!
+1 for this.
(2018-09-21, 10:35 PM)avril Wrote: [ -> ]and then if we could add "by replies count" and "by views count" to sort options, it could be complete.

This is actually already a searching feature of MyBB they have just failed to include it on the actual search.php page, my assumption being those two things were meant only for thread listing sort via a forum. They do however work by being added to the options in the search template.

1) Admin CP --> Templates & Style --> Templates --> Your Current Set --> Search Templates --> search
- From there find:
<select name="sortby">
<option value="lastpost">{$lang->sort_lastpost}</option>
<option value="starter">{$lang->sort_author}</option>
<option value="forum">{$lang->sort_forum}</option>
</select>
- Replace with:
<select name="sortby">
<option value="lastpost">{$lang->sort_lastpost}</option>
<option value="starter">{$lang->sort_author}</option>
<option value="forum">{$lang->sort_forum}</option>
<option value="views">{$lang->sort_views}</option>
<option value="replies">{$lang->sort_replies}</option>
</select>

2) You will notice that the two options we just added in are not showing properly, as in blank, and this is because the language for the two lang-> options we made is missing. So we'll add that in by navigation to our inc/languages/english/search.lang.php file.
- From there find:
$l['sorting_options'] = "Sorting Options";
$l['sort_lastpost'] = "Sort Results by last post date";
$l['sort_author'] = "Sort Results by author";
$l['sort_forum'] = "Sort Results by forum";
- And add in these directly below:
$l['sort_views'] = "Sort Results by view count";
$l['sort_replies'] = "Sort Results by reply count";
that should be "sl" (S and L) and not "s1" (S and One) in the last line
(2018-09-30, 02:52 PM)linguist Wrote: [ -> ]that should be "sl" (S and L) and not "s1" (S and One) in the last line

Eeep! Was typing too quick. Thanks for catching that!
I created a new issue for this with a PR - https://github.com/mybb/mybb/issues/3459
Pages: 1 2