forum pages count
Written on 01/03/11 at 16:29:50 by zalias7
Immediately Sorry for my bad English.

When me the forum pages is as follows:


Image URLX2    Image URLX4

I did, that would be as follows:

Image URLX2    Image URLX4

code from the forum/display.pl

code:
   print_top();
   my $pages = qq~<span class="forumtext"><b><u>$msg{'039'}</u></b> </span>~;
   $nummessages = @messages;
   $c = 0;
   while (($c*$maxmessagedisplay) < $nummessages) {
      $viewc = $c+1;
      $strt = ($c*$maxmessagedisplay);
      if ($start == $strt) { $pages .= "[$viewc] "; }
      else { $pages .= qq~<a
href="$forum&op=$display&num=$viewnum&start=$strt">$viewc</a> ~;
      }
      $c++;
   }



change to:


code:
   print_top();
   my $pages = qq~<span class="forumtext"><b><u>$msg{'039'}</u></b> </span>~;
   $nummessages = @messages;
   $pages=$pages.viens_du($nummessages,$maxmessagedisplay,0,$start,$viewnum);
#   $c = 0;
#   while (($c*$maxmessagedisplay) < $nummessages) {
#      $viewc = $c+1;
#      $strt = ($c*$maxmessagedisplay);
#      if ($start == $strt) { $pages .= "[$viewc] "; }
#      else { $pages .= qq~<a
# href="$forum&op=$display&num=$viewnum&start=$strt">$viewc</a> ~;
#      }
#      $c++;
#   }



and add sub to forum_subs.pl

code:
sub viens_du {
my ($maxhits_1,$maxdisplay,$su_pirmu,$nh,$numeris) =@_;

   # Build the page links list.
$mreplies=$maxhits_1;$start=$nh;$maxmessagedisplay=$maxdisplay;
   my ($pagetxtindex, $pagetextindex, $pagedropindex1, $pagedropindex2, $all, $allselected);

   $postdisplaynum = 5;               # max number of pages to display
   $startpage = 0;
   $max = $mreplies;
   $start = $start > $mreplies ? $mreplies : $start;
   
   $start = (int($start / $maxmessagedisplay)) * $maxmessagedisplay;
   $tmpa = 1;

$as1=($nh/$maxdisplay)+1;
   if ($start >= (($postdisplaynum - 1) * $maxmessagedisplay)) {
      $startpage = $start - (($postdisplaynum - 1) * $maxmessagedisplay);
      $tmpa = int($startpage / $maxmessagedisplay) + 1;
   }

   if ($max >= $start + ($postdisplaynum * $maxmessagedisplay)) { $endpage = $start + ($postdisplaynum * $maxmessagedisplay); } else { $endpage = $max; } #{$endpage=$start +  $maxmessagedisplay;}
   $lastpn = int($mreplies / $maxmessagedisplay) == $mreplies / $maxmessagedisplay ? ($mreplies / $maxmessagedisplay): int($mreplies / $maxmessagedisplay)+1;
   $lastptn = ($lastpn - 1) * $maxmessagedisplay;

         for ($counter = $startpage; $counter < $endpage; $counter += $maxmessagedisplay) {

$numerukas=($tmpa*$maxmessagedisplay)-$maxmessagedisplay;
$pagetxtindex .= $tmpa == $as1 && !$su_pirmu ? qq~<b>$tmpa</b>~ : qq~<a href="$forum&op=display&num=$numeris&start=$numerukas" class="forumlink">$tmpa</a> ~;
            $tmpa++;
         }
$aa="";$cc="";
         if ($endpage < $max - $maxmessagedisplay) {
            $pagetxtindex .= qq~<a href="javascript:void(0);" onclick="ListPages(0);">...</a>~;
$aa=int(($max-$endpage)/$maxmessagedisplay);
$bb= $postdisplaynum <=$aa  ? $postdisplaynum -1: $aa-1;

for($ii=$lastpn-$bb;$ii<$lastpn;$ii++) {
$nnn = ($ii*$maxmessagedisplay)-$maxmessagedisplay;
$pagetxtindex .=qq~<a href="$forum&op=display&num=$numeris&start=$nnn" class="forumlink">$ii</a> ~;
   }
            }

         if ($endpage != $max) {$pagetxtindex .=qq~<a href="$forum&op=display&num=$numeris&start=$lastptn" class="forumlink">$lastpn</a> ~;}
return qq($pagetxtindex);
}



forum topic when it becomes very large, they are starting to look as follows:


Image URLX2    Image URLX4

replace code (cgi-lib/forum.pl (sub mesageindex))


code:
      $nummessages = $mreplies[$b]+1;
      if ($nummessages > $maxmessagedisplay) {
         $c = 0;   my ($viewc, $strt);
      while (($c*$maxmessagedisplay) < $nummessages) {
$viewc = $c+1;$strt = $c*$maxmessagedisplay;
      $pages .= qq~<a href="$forum&op=display&num=$mnum[$b]&start=$strt" class="forumlink">$viewc</a> ~;
      $c++;
         }
         $pages = qq~( <img src="$imagesurl/forum/multipage.gif" alt=""> $pages )~;
      }



to


code:
      my $pages = '';
      $nummessages = $mreplies[$b]+1;
$pages=viens_du($nummessages,$maxmessagedisplay,1,$start,$mnum[$b],0);   
#      if ($nummessages > $maxmessagedisplay) {
#         $c = 0;   my ($viewc, $strt);
#         while (($c*$maxmessagedisplay) < $nummessages) {
#$viewc = $c+1;$strt = $c*$maxmessagedisplay;
#      $pages .= qq~<a href="$forum&op=display&num=$mnum[$b]&start=$strt" class="forumlink">$viewc</a> ~;
#      $c++;
#         }
#         $pages = qq~( <img src="$imagesurl/forum/multipage.gif" alt=""> $pages )~;
#      }



then looks like this forum:


Image URLX2    Image URLX4

I am happy to link to your :)

Other messages in this Thread:
 
 Re: forum pages count
Written on 01/04/11 at 23:11:38 by On
Very nice hack! congratulate

It should be added to the main code.

 Re: forum pages count
Written on 01/05/11 at 17:13:37 by zalias7
Thank you:)
function names can overwrite better English.
Forum for users and I've moved on PostgreSQL, Would you be interested?

 Re: forum pages count
Written on 02/07/11 at 21:59:02 by On

zalias7 said 2 days and 4 hours ago.:
Forum for users and I've moved on PostgreSQL, Would you be interested?



Sounds very interesting!

 Re: forum pages count
Written on 02/14/11 at 07:14:29 by zalias7
When I finish processing the SE version 1.0 V, we will send you, but if you want. to operate and txt version, we need more work:)

Forums and Comments Brought to you by: Open Source, Perl CMS. WebAPP Content Management System (Official).
The comments are owned by the poster. We aren't responsible for its content.