Latest Forum Posts Block Mod
Written on 12/15/04 at 20:08:26 EST by Admin
This is a great mod that is running on the side of the HOME page of this site.

Basically it shows you the last posts made to the forum plus adfditional information, like time, date, how many pages there are to the post, etc...

The code for that is here...


code:
#####################
sub latestforumside {
#####################

boxheader("Latest Posts");

print qq~<tr><td align="left" class="textsmall">~;

open(FILE, "<$boardsdir/cats.txt");
@fcats = <FILE>;
close(FILE);
      
%myforumdata= ();
      
foreach $fcat (@fcats) {
      $fcat =~ s/[\n\r]//g;
      
      open(FILE, "<$boardsdir/$fcat.cat");
      @fcatinfo = <FILE>;
      close(FILE);

      $fcatinfo[1] =~ s/[\n\r]//g;
      foreach $selboard (@fcatinfo) {

      if ($selboard ne $fcatinfo[0] && $selboard ne $fcatinfo[1]) {
      $selboard =~ s/[\n\r]//g;
      
      if ($fcatinfo[1] ne "") {
      if ($settings[7] ne "$root" && $settings[7] ne "$fcatinfo[1]") {
      next;
      }
      }
      
      open(FILE, "<$boardsdir/$selboard.txt");
      @fposts = <FILE>;
      close(FILE);

      for ($f = 0; $f < @fposts; $f++) {
      ($fpnum, $fptitle, $dummy, $dummy, $dummy, $fpdate, $fpreplys, $dummy, $dummy, $dummy, $dummy) = split(/\|/, $fposts[$f]);
      chomp($dummy);
      $lfptitle = censor_it($fptitle);
# --- begin from anton --
      $fpnummessages = $fpreplys+1;
      $c = 0;
      $fppages = "";
      if ($fpnummessages > $maxmessagedisplay) {
      while (($c*$maxmessagedisplay) < $fpnummessages) {
      $viewc = $c+1;
      $strt = ($c*$maxmessagedisplay);
      $fppages = qq~$fppages <a
       href="$pageurl/$cgi?action=forum&amp;board=$selboard&amp;op=display&amp;num=$fpnum&amp;start=$strt"
       class="webapplink">$viewc</a> ~;
      $c++;
      }
      $fppages =~ s/\n$//g;
      $fppages = qq~<BR>( $fppages )~;
      }

      open(FILE, "<$messagedir/$fpnum.txt");
      @fptposts = <FILE>;
      close(FILE);
      for ($t = 0; $t < @fptposts; $t++) {
      ($dummy, $fptposter, $dummy, $dummy, $fptusername, $dummy, $dummy, $dummy, $dummy, $dummy) = split(/\|/, $fptposts[$t]);
      chomp($dummy);
      if ($ftpusername ne $anonuser) {
      $fptuser = $fptusername;
      }
      else {
      $fptuser = $fptposter;
      }
      $myforumlink = qq~<a
       href="$scripturl/$cgi?action=forum&amp;board=$selboard&amp;op=display&amp;num=$fpnum"
       class="whomenu">$lfptitle</a><BR>
      ($fpdate)<BR>by $fptuser $fppages~;
      }
# --- end from anton ---
      ($chkdate, $chktime) = split(/ - /, $fpdate);
      ($chkmonth, $chkday, $chkyear) = split(/\//, $chkdate);
      ($chkhour, $chkmin, $chksec) = split (/:/, $chktime);
      $chkyear = (2000+$chkyear);
      
      $sortedentry = "$chkyear$chkmonth$chkday$chkhour$chkmin$chksec";
      $myforumdata{$sortedentry} = $myforumlink;
      }
      }
      }
      }

@myforumnum = sort { $b <=> $a } keys %myforumdata;

if (@myforumnum) {
   for ($myflcounter = 0; $myflcounter < @myforumnum && $myflcounter < 5; $myflcounter++) {
   print qq~$myforumdata{$myforumnum[$myflcounter]}<br>~;
      }
  }

print qq~</td></tr>~;

boxfooter();

}



And of course you have to play the line to call the sub where you want it in your plugins.pl...  well they both go there, just seperate to make things more clear, or more complicated...  however you look at it.

I have this installed in my Right Top plugin spot.  the code is...


code:
latestforumside();


Other messages in this Thread:
 
 Re: Latest Forum Posts Block Mod
Written on 12/15/04 at 20:09:07 EST by Admin
This mod is a Bantychick / Anton creation as I can see...

Or maybe they just fixed up the code and made it more friendly...  I will leave the credit up to them to take.

Forums and Comments Brought to you by: www.2xlnt.com - WA
The comments are owned by the poster. We aren't responsible for its content.