MyBB Community Forums

Full Version: Search Results Sometimes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have been working away on my board and I have got a fairly nice set up for my "Recent Posts" - it sort of matches my forum display and I am pretty pleased with it - except the title. On my forumdisplay I have the name of the forum at the top - but in the "Recent Posts" the header is of course Search Results.

I do want my users to be able to use search and get "Search Results" on the navigation bar/page title when they run a standard search - but not when they use the search query that returns the Recent Posts - that I want to say "Recent Posts".

I have template conditionals and patches plugin ready to use if anyone knows the trick to make this happen.

For the bewildered, here are links to what I mean:

Forumdisplay
Recent posts
Search of all my threads
Doubt this to be possible without a plugin. You will need a new table field to be filled upon the search type being made (not 'resulttype'), then modify the title (possible with template conditionals) depending on that.

A simple plugin actually, it looks.
Yea? I have no idea where to start Big Grin
That is what this forum is for Toungue

Add your row in your installation function
function *_install()
{
	global $db;

	if(!$db->field_exists('action', 'searchlog'))
	{
		$db->add_column('searchlog', 'action', 'varchar(10) NOT NULL default \'\'');
	}
}

Check if it was inserted in your _is_installed check function:
function *_is_installed()
{
	global $db;

	return $db->field_exists('action', 'searchlog');
}

Drop it in your un-installation function:
function *_uninstall()
{
	global $db;

	if($db->field_exists('action', 'searchlog'))
	{
		$db->drop_column('searchlog', 'action');
	}
}

Now hook at (I assume you mean the "Get new posts" feature) search_do_search_process and add your action to the search insert array:
$plugins->add_hook('search_do_search_process', 'my_hook');
function my_hook()
{
	global $db, $searcharray, $mybb;

	$searcharray['action'] = $db->escape_string($mybb->input['action'])
}

Now you can use the following in your "search_results*" templates:
<if $search['action'] == 'getnew' then>New Posts<else>Search Reults</if>

P.S: Add your _info function too.

I'm not a good at teaching, sorry Toungue
Ok, I shall try it. Thank you Omar. I will be back when my board explodes Big Grin
yay it works Big Grin

Attached if anyone wants it
No explosion? Sad

Toungue
Just a little one - the semi-colon was missing on the search hook. That was a test right? Big Grin
Right, it was. ... Big Grin

Glad it worked.
This is awesome! Thanks!