Baffled has asked for the wisdom of the Perl Monks concerning the following question:
OK here is my delima that I seek the wisdom of the monks on. I have a page navigation bar at the bottom of the page that the client has asked appear on the top as well as the bottom of the page. Seems simple so far...
However I find on the first page (page=0) that the top navigation does not work, but works fine on the 2nd and additional pages. The foreach statement comes in after the top header and I believe that it because it has not counted the items and pages yet and that is why it is not able to show the pages correctly on the first page. I have tried over and over to maybe move the count higher in the page before where I would place the page count bar but to no avail.
To see the page in question that is generated from the following code simply go to 2bidlive DOT com and click on "Enter The Auction" and you will see what Im talking about. I have left it as is so you can see when you click onto the next page from the bottom then the top will work.
my $nowtime = localtime int($config{'time'}); opendir THEDIR, "$config{'basepath'}$form{'category'}" or &oops("C +ategory directory $form{'category'} could not be opened."); my @allfiles = grep -T, map "$config{'basepath'}$form{'category'}/ +$_", sort { int($a) <=> int($b) } (readdir THEDIR); closedir THEDIR; my $file; my @cellcolor=($config{'odd_row_color'},$config{'even_row_color'}) +; my $color = 0; my $pagebreak = int $form{pb} || 30; my ($icount, $pcount) = (0,0); print "<div align=center><center><table height=30 border=1 cellpad +ding=0 cellspacing=0 width=100% bordercolor=$config{'bordercolor'}>\n +"; print "<tr><td align=center width=100% bgcolor=$config{'colortable +head0'}><font face=arial size=3> <font color=$config{'text0'}><b +>All Items - $category{$form{'category'}}</b></td></tr></table></cent +er></div>\n"; print "<font face=arial size=3><div align=center><center><table bor +der=0 cellpadding=0 cellspacing=0 width=100%><tr><td width=100% bgcol +or=$config{'colortablehead0'} height=3></td></tr></table></center></d +iv><br>\n"; pagebreak($pcount,$pagebreak); # This is where I have t +he top pagebreak navigation bar print "<BR><BR>\n" print "<table border=0 cellpadding=1 cellspacing=2 width=100% borderc +olor=$config{'bordercolor'}>\n"; print "<TR><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead0'} WID +TH=12\%><font color=$config{'text0'} face=arial size=2><B>Status</B>< +/font><TD ALIGN=CENTER BGCOLOR=$config{'colortablehead0'} width=40\%> +<font color=$config{'text0'} face=arial size=2><B>All Items - $catego +ry{$form{'category'}}</B></font></TD><TD ALIGN=CENTER BGCOLOR=$config +{'colortablehead0'} width=6\%><font color=$config{'text0'} face=arial + size=2><B>Price</B></font></TD><TD ALIGN=CENTER BGCOLOR=$config{'col +ortablehead0'} width=5\%><font color=$config{'text0'} face=arial size +=2><B>Bids</B></font></TD><TD ALIGN=CENTER BGCOLOR=$config{'colortabl +ehead0'} width=14\%><font color=$config{'text0'} face=arial size=2><B +>High Bidder</B></font></TD><TD ALIGN=CENTER BGCOLOR=$config{'colorta +blehead0'} width=10\%><font color=$config{'text0'} face=arial size=2> +<B>Closes $config{'timezone'}</B></font></TD><TD ALIGN=CENTER BGCOLOR +=$config{'colortablehead0'} width=13\%><font color=$config{'text0'} f +ace=arial size=2><B>Options</B></font></TD></TR>\n"; foreach $file (@allfiles) { $icount++; if($icount > $pagebreak){$icount=1; $pcount++} next if $pcount != $form{page}; $file =~ s/^$config{'basepath'}$form{'category'}\///; $file =~ s/\.dat$//; my ($title, $reserve, $inc, $desc, $image1, $image2, $image3, +$image4, $thumb1, $thumb2, $thumb3, $thumb4, $dutch, $qty, $bold, $hi +ghlight, $feat, $catfeat, $grabber, $relist, $buyit, $gallery, $count +er, $ship1, $ship2, $ship3, $ship4, $ship5, $shipcost, $location, $pa +y1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $pay9, $paypal, +$idata1, $idata2, $idata3, $idata4, $idata5, $idata6, $idata7, $idata +8, $idata9, @bids) = &read_item_file($form{'category'},$file); chomp($title, $reserve, $inc, $desc, $image1, $image2, $image3 +, $image4, $thumb1, $thumb2, $thumb3, $thumb4, $dutch, $qty, $bold, $ +highlight, $feat, $catfeat, $grabber, $relist, $buyit, $gallery, $cou +nter, $ship1, $ship2, $ship3, $ship4, $ship5, $shipcost, $location, $ +pay1, $pay2, $pay3, $pay4, $pay5, $pay6, $pay7, $pay8, $pay9, $paypal +, $idata1, $idata2, $idata3, $idata4, $idata5, $idata6, $idata7, $ida +ta8, $idata9, @bids); my @firstbid = split(/\[\]/,$bids[0]); my @lastbid = split(/\[\]/,$bids[$#bids]); my $usersfeed = &feeder($firstbid[0],2); my $usersfeed2 = &feeder2($firstbid[0],2); my $bidderfeed = &feeder($lastbid[0],2); if ($title ne '') { my ($alias, $email, $bid, $time, $add1, $add2, $add3, $oqt +y, $qtysold) = &read_bid($bids[$#bids]); my ($selleralias, $selleremail, $sellerbid, $sellertime, $ +selleradd1, $selleradd2, $selleradd3) = &read_bid($bids[0]); my $timeleft = &timeleft($file); my $imagedisp = "<IMG SRC=$thumb1 BORDER=0>"; my $rowcolor; if ($highlight eq "Yes") { $rowcolor = $config{'yellowrow'}; } else { $rowcolor = $cellcolor[$color]; } if ($alias eq $selleralias){ $bidderfeed = "No bids yet..."; my $lastbid = $sellerbid; } else { $bidderfeed = "$bidderfeed"; } if ($bold eq $config{'bolditemnum'}) { print "<TR><TD align=left BGCOLOR=$rowcolor>"; print "<br><left><table width=80 height=80 bgcolor=000 +000><tr><td align=center><A HREF=$ENV{'SCRIPT_NAME'}\?category=$form{ +'category'}\&item=$file>$imagedisp</a></td></tr></table>" if ($thumb1 +); print "<TD BGCOLOR=$rowcolor><font face=arial size=2> +<A HREF=$ENV{'SCRIPT_NAME'}\?category=$form{'category'}\&item=$file>< +b>$title</b></A></font>"; print " <IMG SRC=$config{'buyiticonsm'}>" if (($buyit > + 0) && ($#bids < 1)); print "</TD><TD align=right BGCOLOR=$rowcolor><font face=a +rial size=2><b>$config{'currency'}$bid</b></font></TD><TD align=cente +r BGCOLOR=$rowcolor><font face=arial size=2>$#bids</font></TD><TD ali +gn=center BGCOLOR=$rowcolor><font face=arial size=2>$bidderfeed</font +></TD><TD BGCOLOR=$rowcolor><font face=arial size=2>$timeleft</font>< +/TD><td BGCOLOR=$rowcolor align=center><A HREF=$ENV{'SCRIPT_NAME'}\?c +ategory=$form{'category'}\&item=$file><img src=\"http://auctionblock. +bidderssite.com/images/viewitembut.png\" border=\"0\"></a><br><br><A +HREF=$ENV{'SCRIPT_NAME'}\?action=trackitem&category=$form{'category'} +&item=$file><img src=\"http://auctionblock.bidderssite.com/images/wat +chbutton.png\" border=\"0\"></a><br><a href=$ENV{'SCRIPT_NAME'}\?acti +on=mailto&category=$form{'category'}&item=$file><img src=\"http://auc +tionblock.bidderssite.com/images/send2friend.png\" border=\"0\"></a>< +/td></TR>\n"; $color = int(!($color)); } else { print "<TR><TD align=left BGCOLOR=$rowcolor>"; print "<br><left><table width=80 height=80 bgcolor=000 +000><tr><td align=center><A HREF=$ENV{'SCRIPT_NAME'}\?category=$form{ +'category'}\&item=$file>$imagedisp</a></td></tr></table>" if ($thumb1 +); print "</TD><TD BGCOLOR=$rowcolor><font face=arial size=2> +<A HREF=$ENV{'SCRIPT_NAME'}\?category=$form{'category'}\&item=$file>$ +title</A></font>"; print " <IMG SRC=$config{'buyiticonsm'}>" if (($buyit > 0) +&& ($#bids < 1)); print "</TD><TD align=right BGCOLOR=$rowcolor><font face=a +rial size=2><b>$config{'currency'}$bid</b></font></TD><TD align=cente +r BGCOLOR=$rowcolor><font face=arial size=2>$#bids</font></TD><TD ali +gn=center BGCOLOR=$rowcolor><font face=arial size=2>$bidderfeed</font +></TD><TD BGCOLOR=$rowcolor><font face=arial size=2>$timeleft</font>< +/TD><td BGCOLOR=$rowcolor align=center><A HREF=$ENV{'SCRIPT_NAME'}\?c +ategory=$form{'category'}\&item=$file><img src=\"http://auctionblock. +bidderssite.com/images/viewitembut.png\" border=\"0\"></a><br><br><A +HREF=$ENV{'SCRIPT_NAME'}\?action=trackitem&category=$form{'category'} +&item=$file><img src=\"http://auctionblock.bidderssite.com/images/wat +chbutton.png\" border=\"0\"></a><br><a href=$ENV{'SCRIPT_NAME'}\?acti +on=mailto&category=$form{'category'}&item=$file><img src=\"http://auc +tionblock.bidderssite.com/images/send2friend.png\" border=\"0\"></a>< +/td></TR>\n"; $color = int(!($color)); } } } print "</TABLE>\n"; print "<font face=arial size=3><div align=center><center><table bo +rder=0 cellpadding=0 cellspacing=0 width=100%><tr><td width=100% bgco +lor=$config{'colortablehead0'} height=3></td></tr></table></center></ +div><br>\n"; pagebreak($pcount,$pagebreak); # This is the bottom pagebrea +k navigation bar print "<BR><BR>\n";
sub pagebreak{ my $begin = "<center>"; my $next = "Next Page >>"; my $nonext = "Next Page >>"; my $previous = "<< Previous Page"; my $noprevious = "<< Previous Page"; my $end = "</center>"; my $urlfragment; foreach(keys %form){ next if($_ eq 'pb' || $_ eq 'page'); my $f = $form{$_}; $f=~s/(\W)/'%'.unpack("H2", $1)/eg; $urlfragment.='&' if $urlfragment; $urlfragment.="$_=$f"; } my($pcount, $pagebreak) = @_; # Print Pagebreak Links print $begin; if($form{page} > 0){ print " <a href=$ENV{SCRIPT_NAME}?$urlfragmen +t&page=@{[$form{page}-1]}&pb=$form{pb}>$previous</a> " } else{ print " $noprevious " } print "|"; for(0..$form{page}-1){ print " <a href=$ENV{'SCRIPT_NAME'}?$urlfra +gment&page=$_&pb=$form{pb}>@{[$_+1]}</a> " } print " <b>", int($form{page})+1, "</b> "; for($form{page}+1..$pcount){ print " <a href=$ENV{'SCRIPT_NAME'}?$ +urlfragment&page=$_&pb=$form{pb}>@{[$_+1]}</a> " } if($pcount>0){ print " <a href=$ENV{'SCRIPT_NAME'}?$urlfragment&pb +=@{[(1+$pcount)*$pagebreak]}>All</a> " } print "|"; if($form{page} < $pcount){ print " <a href=$ENV{'SCRIPT_NAME'}?$ur +lfragment&page=@{[$form{page}+1]}&pb=$form{pb}>$next</a> " } else{ print " $nonext " } print $end; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Showing Pagebreak Navigation on top and bottom of pages before foreceach statement?
by Corion (Patriarch) on Aug 05, 2011 at 07:54 UTC | |
|
Re: Showing Pagebreak Navigation on top and bottom of pages before foreceach statement?
by duyet (Friar) on Aug 05, 2011 at 09:03 UTC |