I was asked in another thread if this could be adopted to have multiple 'master forums' and yes it can, I shied away from sharing this because I didn't want to make it too daunting looking for most users who only need 1 master forum.
To have multiple master forums simply add an "elseif" statement below the if { } code and above the else { } code... for example in the first edit add to the middle:
PHP Code:
elseif ($foruminfo[forumid] == 7) {
$threadscount = $db->query_first_slave("
SELECT COUNT(*) AS threads, SUM(IF(thread.lastpost > $lastread AND open <> 10, 1, 0)) AS newthread
$hook_query_fields
FROM " . TABLE_PREFIX . "thread AS thread
$tachyjoin
$hook_query_joins
WHERE forumid IN (7, 8, 9, 10)
AND sticky = 0
$prefix_filter
$visiblethreads
$globalignore
$limitothers
$datecut
$hook_query_where
");
}
This would make the entire code for the first edit look like:
PHP Code:
//Edit added if-else statement
if ($foruminfo[forumid] == 2) {
$threadscount = $db->query_first_slave("
SELECT COUNT(*) AS threads, SUM(IF(thread.lastpost > $lastread AND open <> 10, 1, 0)) AS newthread
$hook_query_fields
FROM " . TABLE_PREFIX . "thread AS thread
$tachyjoin
$hook_query_joins
WHERE forumid IN (2, 3, 4, 5)
AND sticky = 0
$prefix_filter
$visiblethreads
$globalignore
$limitothers
$datecut
$hook_query_where
");
}
elseif ($foruminfo[forumid] == 7) {
$threadscount = $db->query_first_slave("
SELECT COUNT(*) AS threads, SUM(IF(thread.lastpost > $lastread AND open <> 10, 1, 0)) AS newthread
$hook_query_fields
FROM " . TABLE_PREFIX . "thread AS thread
$tachyjoin
$hook_query_joins
WHERE forumid IN (7, 8, 9, 10)
AND sticky = 0
$prefix_filter
$visiblethreads
$globalignore
$limitothers
$datecut
$hook_query_where
");
}
else {
$threadscount = $db->query_first_slave("
SELECT COUNT(*) AS threads, SUM(IF(thread.lastpost > $lastread AND open <> 10, 1, 0)) AS newthread
$hook_query_fields
FROM " . TABLE_PREFIX . "thread AS thread
$tachyjoin
$hook_query_joins
WHERE forumid = $foruminfo[forumid]
AND sticky = 0
$prefix_filter
$visiblethreads
$globalignore
$limitothers
$datecut
$hook_query_where
");
}
In this case you'd change the number 7 to your second master forum id, and 7,8,9,10 to your secondary forum id's (and your master).
You can add as many elseif { } statements as you need for various master forums, and you can even have secondary forums be shared between multiple master forums so forumid '10' for example can be a secondary forum of master forum 2 and 7, there is no problem doing this.
Once you make this elseif{} addition for the first edit you need to make similar edits for the second (optional) and third (required) edits. Just copy the entire 'if' statement for each starting with "if" and ending with "}" then copy and paste it below the if statement, change it from "if" to "elseif" and set the forum id numbers as needed.
It sounds more complicated then it is but can get messy quick if you have a lot of master forums... on the plus side conditionals are very efficient as coding goes and there should be no noticeable decrease in performance no matter how many you realistically have.