MyBB Community Forums

Full Version: View new posts feature
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there any way to exclude a forum/category from view new posts?
Not easily - it can be done via a custom code/plugin however. If you look in search.php, and find:

$mybb->input['action'] == "getnew"

The section after this piece of code strings together an SQL search query. Looking through the code, I can see:

if($inactiveforums)
	{
		$where_sql .= " AND t.fid NOT IN ($inactiveforums)";
	}

If you change this to...

if($inactiveforums)
	{
		$where_sql .= " AND t.fid NOT IN ($inactiveforums)";
	}

		$where_sql .= " AND t.fid NOT IN x, x, x";

...replacing the x in the last part to the forums you don't want searched. The last x in your query doesn't need a comma after it (as above).

Also, note that forums that are not in the user's permission to view or inactive forum aren't included in the search by default. This code isn't tested...
That returns

Quote:SQL Error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'x, x, 33 AND t.visible>-1 AND t.closed NOT LIKE 'moved|%'' at line 1
Query:
SELECT t.tid FROM threads t WHERE t.lastpost >= '1230668169' AND t.fid NOT IN ('43','44','46','53') AND t.fid NOT IN x, x, 33 AND t.visible>-1 AND t.closed NOT LIKE 'moved|%'
with 33 being the number I entered like
	if($inactiveforums)
	{
		$where_sql .= " AND t.fid NOT IN ($inactiveforums)";
	}
	$where_sql .= " AND t.fid NOT IN x, x, 33";
Don't leave the x in.....
(2008-12-30, 09:19 PM)MattR Wrote: [ -> ]Don't leave the x in.....
Tried that too and it leaves basic the same thing
Quote:SQL Error:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 AND t.visible>-1 AND t.closed NOT LIKE 'moved|%'' at line 1
Query:
SELECT t.tid FROM threads t WHERE t.lastpost >= '1230668169' AND t.fid NOT IN ('43','44','46','53') AND t.fid NOT IN 1 AND t.visible>-1 AND t.closed NOT LIKE 'moved|%'
You need to place parentheses around the list of fids, even if there are only one.

Example to exclude 1 forum:
if($inactiveforums)
	{
		$where_sql .= " AND t.fid NOT IN ($inactiveforums)";
	}

		$where_sql .= " AND t.fid NOT IN (1)";
Example to exclude multiple forums:
if($inactiveforums)
	{
		$where_sql .= " AND t.fid NOT IN ($inactiveforums)";
	}

		$where_sql .= " AND t.fid NOT IN (1, 5, 60)";
Works like a charm with the parentheses. Many thanks

I hate syntax