Thread: Sub-Forums
View Single Post
  #55  
Old 12-02-2001, 07:33 PM
george_proost george_proost is offline
 
Join Date: Nov 2001
Posts: 69
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

?0.02

I used the basis of the hack. Modified extremely... and works great. Does not generate many extra queries, and is damn fast.

Features added :
- Bold on new messages
- custom forum type
- variable number of columns to display per parents children

added 2 fields to forum table showas and numcols
this is the index.php version. For the forumdisplay.php
there is some stuff to comment out ( or in) dependeing on your requirements (sorts out spacing before and after subforum lists)

See it in action at www.mainframeforum.com

here is the code, I do not support it, have fun .....
PHP Code:
// ********************************************************************
// ADDED BY ERK 
// ********************************************************************
$subforums=$DB_site->query("select title,forumid,lastpost,replycount,threadcount,showas,numcols from forum where parentid = $forum[forumid] and active != 0 ORDER BY parentid,displayorder"); 
if (
$DB_site->num_rows($subforums)>0
  { 
  
$subs "<smallfont><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\" id=\"ltlink\" ><tr valign=\"top\"> "

  
$num_cols  $forum[numcols];
  
$col_width floor(100/$num_cols);  
  
$num_rows  ceil($DB_site->num_rows($subforums)/$num_cols);
  
$cur_col   0;
  
$cur_row   1;

  while (
$forum_child=$DB_site->fetch_array($subforums)) 
    { 
    
$permission=$DB_site->query_first("select accessmask from access where userid = $bbuserinfo[userid] AND forumid = $forum_child[forumid]"); 
    if (
$permission['accessmask'] != || $permission['accessmask'] == null
      { 
      
// ------------------------------
      // check new messages in subforum
      // and set 'bolding' attributes
      // ------------------------------
        
$bold_on "";
        
$bold_off ""
        if (
$bbuserinfo['lastvisitdate']=='Never') {
          
$bold_on "<b>";
          
$bold_off "</b>";
         } else {
           if (isset(
$bbforumview[$forum_child['forumid']]) and $bbforumview[$forum_child['forumid']]>$bbuserinfo['lastvisit']) {                $userlastvisit=$bbforumview[$forum_child['forumid']];
            } else {
                
$userlastvisit=$bbuserinfo['lastvisit'];
            }
        if (
$userlastvisit<$forum_child['lastpost']) {
          
$bold_on "<b>";
          
$bold_off "</b>";
        } else {
          
$bold_on "";
          
$bold_off "";
        }
      }

    if (
$cur_row == 1)
        {
        
$subs.="<td width=\"$col_width%\">";
    
        
$cur_col++;
        }
    
$subs.="<table cellspacing=\"0\" cellpadding=\"1\" border=\"0\" width=\"100%\"><tr valign=\"top\" ><td nowrap><font class=\"sf\">- </td><td width=\"100%\">";
    
$subs.="<a href=\"$bburl/f$forum_child[forumid]/s\">";
    
$child_text "$bold_on$forum_child[title]$bold_off&nbsp;"

    
// switch on showas
    
switch ($forum_child[showas])
    {
    
//  FULL AFFILIATES 
    
case "AFF":
      
$subs.="<font class=\"sf\" color=\"darkblue\">$child_text</font></a><img src=\"$bburl/images/star.gif\">";  
      break;
    case 
"AFF_AS":
      
$subs.="<font class=\"sf\" color=\"white\">$child_text</font></a><img src=\"$bburl/images/star.gif\">";  
      break;
    
//  VENDOR MODERATED
    
case "VEN":
        
$subs.="<font class=\"sf\" color=\"black\">$child_text</font></a><img src=\"$bburl/images/posticonnew.gif\">";
      break;  
    
//  CONTRIBUTOR MODERATED
    
case "CON":
      
$subs.="<font class=\"sf\" color=\"darkgreen\">$child_text</font></a><img src=\"$bburl/images/paperclip.gif\">";   
      break;
    
//  USENET FORUM ENTRIES
    
case "USE":
      
$subs.="<font class=\"sf\" color=\"brown\">$child_text</font></a><img src=\"$bburl/images/posticon.gif\">";
      break;
    
//  MEMBER MODERATED
    
case "MEM":
      
$subs.="<font class=\"sf\" color=\"darkorange\">$child_text</font></a>";  
      break;
    
//  HIDDEN 
    
case "LOW":
      
$subs.="<font class=\"sf\" color=\"#999999\">$child_text</font></a>"
      break;
    
//  DEFAULT
    
default:
      
// ------------------------------- 
      // set entry to italic if no posts
      // -------------------------------
      // if ($forum_child[threadcount] == 0 ){
      //   $subs.="<font class=\"sf\" color=\"black\"><i>$child_text</i></font></a>";  
      // } else {
        
$subs.="<font class=\"sf\" color=\"black\">$child_text</font></a>"
      
// }      
      
break; 
    } 
// end switch

    // ---------------------
    // tag on the replycount
    // ---------------------
    // if ($forum_child[threadcount] > 0 ){
    //  $subs.="<font class=\"sf\" color=\"#999999\">&nbsp;&nbsp;<i>Posts($forum_child[replycount])</i></font>";
    // }

    // ---------------------------------------
    // check if i need to go to new column yet
    // ---------------------------------------
    
if ($cur_row == $num_rows) { 
      
$cur_row=1$subs.= "</td></tr></table></td>";
      }
    else {
      
$cur_row++; 
      
$subs.="</td></tr></table>";
      }
    
  } 
// end-if 
}  // end-while

  // -------------------------------------  
  // close off the remaining empty columns
  // and finish off the table etc..
  // -------------------------------------
  
$todo_cols $num_cols $cur_col;
  while (
$todo_cols != 0)
  {
    
$subs.="<td width=\"$col_width%\"></td>" ;
    
$todo_cols--;
  }
  
$subs.="</tr></table></smallfont>";
  
  if (
$forum['description'] != '') {
    
$forum['description'].= "<br><br>$subs<br>";                
    }
  else {
    
$forum['description'].= "<br>$subs";                  // used in index.php
    // $forum['description'].= "<br>$subs<br>";                 // used in forumdisplay.php
    
}

  
$subs=null;
// end-if
else {
  
 if (
$forum['description'] != '') {
  
//  $forum['description'].= "<br><br>";                     // used in forumdisplay.php 
 

  else  {
  
// $forum['description'].= "<br>";                     // used in forumdisplay.php 
  
}

}

$DB_site->free_result($subforums); 
$forum_child=null;
 
// ********************************************************************
// END ADDED
// ******************************************************************** 
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02417 seconds
  • Memory Usage 1,860KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete