Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.7 > vBulletin 3.7 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Master Forum / All Topics - View Posts from Multiple Forums in a Single Forum Details »»
Master Forum / All Topics - View Posts from Multiple Forums in a Single Forum
Version: 1.00, by BirdOPrey5 (Senior Member) BirdOPrey5 is offline
Developer Last Online: Aug 2023 Show Printable Version Email this Page

Category: Forum Display Enhancements - Version: 3.7.x Rating:
Released: 07-04-2010 Last Update: Never Installs: 3
Supported
Code Changes Translations  

Note: This mod was developed for 3.8.x but I have confirmed it works the same for 3.7.x, visit the 3.8 mod for some extra options: https://vborg.vbsupport.ru/showthread.php?t=245414 it is the same instructions and code.

This is a way to display posts from various forums and/or subforums in a single forum. This is in part based on this article: https://vborg.vbsupport.ru/showthread.php?t=181876 which allows you to view sub-forum posts in the parent forum. This mod goes a step further and lets you view posts from any forum, subforum or not, and only does so for a single forum, not every forum like the original article.

See post # 2 in this thread for an option for having multiple master forums.

Note: This does not share posts between different sites (domains), merely between forums (categories) on your own site. If you need to share posts between completely different sites check out this mod. (not mine!)

Another Note: You need go edit the forumdisplay.php file to do this, I strongly suggest you backup this file by making a copy before editing and calling it forumdisplay.old or such so you can easily switch back if something goes wrong. I also suggest you close your forum while making these changes.

This mod adds NO additional queries to the database, it should be very efficient.

Open forumdisplay.php in your favorite text editor.

There are two to three edits we have to make, the first and last are required, the middle one is optional- I will explain when we get to it.

Note: See post #4 in the 3.8 thread for an option to let users choose to enable/disable the system. If you want to do this follow the instructions in post 4 before making the edits.

Edit 1. Find:
PHP Code:
    $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 
Replace with:
PHP Code:
//Edit added if-else statement
if ($foruminfo[forumid] == 1) {
    
$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 (1, 2, 3)
            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 the code above replace the number 1 in the if ($foruminfo[forumid] == 1) statement with the forum id of what you want to be the "Master Forum" - The forum from which you can view the other forum's posts.
Also replace the numbers 1,2,3 in the WHERE forumid IN (1, 2, 3) statement with the forum id's of all the forums you want to be able to view the posts of, you can have as many or as few forum ids here as you want, I have about 18 myself. Be sure you include the number of the "Master Forum" in this set. Separate id's with commas.

On to our second edit. This one is a little trickier because it's already inside an IF statement but follow exactly and you'll be OK...

This is the optional edit. Make this edit only if you want sticky threads from the other forums to appear as sticky threads in the "Master Forum." This could get ugly if you have stickies in every forum like I do so personally I skipped this step but tested it to make sure it works. Note: If you don't do this sticky threads will not show at all in the "Master Forum" until unstuck from their respective forum.
Edit 2 (Optional). Find:
PHP Code:
        $stickies $db->query_read_slave("
            SELECT thread.threadid, lastpost, open
            FROM " 
TABLE_PREFIX "thread AS thread
             WHERE forumid = 
$foruminfo[forumid]
                AND sticky = 1
                
$prefix_filter
                
$visiblethreads
                
$limitothers
                
$globalignore 
Replace With:
PHP Code:
 //Edit added if-else statement
           
if ($foruminfo[forumid] == 1) {
        
$stickies $db->query_read_slave("
            SELECT thread.threadid, lastpost, open
            FROM " 
TABLE_PREFIX "thread AS thread
            WHERE forumid IN (1, 2, 3)
                AND sticky = 1
                
$prefix_filter
                
$visiblethreads
                
$limitothers
                
$globalignore
        "
);
        }
        else {
        
$stickies $db->query_read_slave("
            SELECT thread.threadid, lastpost, open
            FROM " 
TABLE_PREFIX "thread AS thread
             WHERE forumid = 
$foruminfo[forumid]
                AND sticky = 1
                
$prefix_filter
                
$visiblethreads
                
$limitothers
                
$globalignore
        "
);        
        } 
Like before change the numbers in the if and where statements to your needs.

Edit 3 (required). Find:
PHP Code:
    $getthreadids $db->query_read_slave("
        SELECT " 
iif($sortfield == 'voteavg'$votequery) . " thread.threadid,
            
$tachy_columns
            
$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
        ORDER BY sticky DESC, 
$sqlsortfield $sqlsortorder. (!empty($sqlsortfield2) ? ", $sqlsortfield2 $sqlsortorder'') . "
        LIMIT 
$limitlower$perpage
    "
); 
Replace With:
PHP Code:
//Edited added if-else statement
  
if ($foruminfo[forumid] == 1){
     
$getthreadids $db->query_read_slave("
        SELECT " 
iif($sortfield == 'voteavg'$votequery) . " thread.threadid,
            
$tachy_columns
            
$hook_query_fields
        FROM " 
TABLE_PREFIX "thread AS thread
        
$tachyjoin
        
$hook_query_joins
          WHERE forumid IN (1, 2, 3)
            AND sticky = 0
            
$prefix_filter
            
$visiblethreads
            
$globalignore
            
$limitothers
            
$datecut
            
$hook_query_where
        ORDER BY sticky DESC, 
$sqlsortfield $sqlsortorder. (!empty($sqlsortfield2) ? ", $sqlsortfield2 $sqlsortorder'') . "
        LIMIT 
$limitlower$perpage
    "
); 
}
  else {
    
$getthreadids $db->query_read_slave("
        SELECT " 
iif($sortfield == 'voteavg'$votequery) . " thread.threadid,
            
$tachy_columns
            
$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
        ORDER BY sticky DESC, 
$sqlsortfield $sqlsortorder. (!empty($sqlsortfield2) ? ", $sqlsortfield2 $sqlsortorder'') . "
        LIMIT 
$limitlower$perpage
    "
);

Once again change the numbers in the if and where statements to your needs.

Now wipe the sweat off your face and save and upload the file. Make sure this file has the same chmod (read/write permissions) as your original forumdisplay.php file.

I suggest making a few test posts to make sure everything is working like you expect before re-opening your forum.

Why would anyone do this you might ask... All I can say is that if you never thought about this you probably don't need it, but I've been looking for this for 2 years with numerous requests for it that went unanswered. I have a mainly off-topic forum but I like to 'file' my posts into various 'on-topic' categories where appropriate. Many users complained about threads being moved because some didn't like browsing sub-forums although I feel it was essential to move them for future reference, archiving, and SEO purposes. This basically solves the problem of people who want one massive OT forum and those who like to keep things neat and apart.

I'm sorry all of these are manual edits... if someone can find a way to make these automatic they have my permission to release it as their own mod, for the good of the community.

Please remember to mark as installed if you use this.

NEW: See posts 6 and 7 in the 3.8 thread for a couple of additional options you may be interested in if using this mod.

Screen Shots- The first one is the original forum the post was made in, in this case "Off Topic Light." The second image is the "Master Forum" or "Off Topic," as you can see the the top post from the secondary forum is also listed in the master forum. All posts from the secondary forum are also in the Master forum, just further down the page then the screen shot captures.
SS1: https://vborg.vbsupport.ru/attachmen...4&d=1277758531
SS2: https://vborg.vbsupport.ru/attachmen...5&d=1277758531

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 07-06-2010, 04:41 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:17 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08813 seconds
  • Memory Usage 2,309KB
  • Queries Executed 17 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (8)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (2)post_thanks_box
  • (2)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (2)post_thanks_postbit_info
  • (1)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete