Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

makepagenav suggestion

Asked Modified Viewed 4,671 times
D
dfmurphy
D
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 19 threads in the forums
  • Started this discussions
asked
Member

This function does something that isn't a major bug, but could be tweaked to function better. First, an example:

If you've got 50 records and use makepagenav(0, 15, 50, 2), you will get four buttons and they'll look like this: [1] [2] [3] ... [4]

If you go to page 4, it will look like: [1] ... [2] [3] [4]

You don't really need the "..." in these cases. They should be there if something is missing, but no page buttons are missing. If I had 65 records instead of 50, then the function shows "..." in the correct place, i.e.: [1] [2] [3] ... [5]

To allow for this kind of exception, I tweaked the function as follows:

In 7.00.05, this function is lines 753-793.
function makepagenav($start, $count, $total, $range = 0, $link = "") {

   global $locale;

   if ($link == "") { $link = FUSION_SELF."?"; }

   $pg_cnt = ceil($total / $count);
   if ($pg_cnt <= 1) { return ""; }

   $idx_back = $start - $count;
   $idx_next = $start + $count;
   $cur_page = ceil(($start + 1) / $count);

   $res = $locale['global_092']." ".$cur_page.$locale['global_093'].$pg_cnt.": ";

   if($idx_back >= 0) {
[color=#ff0000]      if ($cur_page > ($range + 1)) {
         $res .= "<a href='".$link."rowstart=0'>1</a>";
         if ($cur_page != ($range + 2)) {
            $res .= "...";
         }
      }[/color]
   }
   $idx_fst = max($cur_page - $range, 1);
   $idx_lst = min($cur_page + $range, $pg_cnt);
   if ($range == 0) {
      $idx_fst = 1;
      $idx_lst = $pg_cnt;
   }
   for ($i = $idx_fst; $i <= $idx_lst; $i++) {
      $offset_page = ($i - 1) * $count;
      if ($i == $cur_page) {
         $res .= "<span><strong>".$i."</strong></span>";
      } else {
         $res .= "<a href='".$link."rowstart=".$offset_page."'>".$i."</a>";
      }
   }
   if ($idx_next < $total) {
[color=#ff0000]      if ($cur_page < ($pg_cnt - $range)) {
         if ($cur_page != ($pg_cnt - $range - 1)) {
            $res .= "...";
         }
         $res .= "<a href='".$link."rowstart=".($pg_cnt - 1) * $count."'>".$pg_cnt."</a>\n";
      }[/color]
   }
   
   return "<div class='pagenav'>\n".$res."</div>\n";
}


I'm not sure if I made case clearly. Am I on the right track here? I've tested this, but there might something I'm missing. Does anybody want to check my work?
Edited by dfmurphy on 21-01-2009 06:07,
0 replies

4 posts

M
muscapaul
M
Paul

Time flies like an arrow, fruit flies like banana (Groucho Marx)

Sites: Diptera.info (site owner); Online-Keys.net (site owner); Sciomyzidae.info (site co-owner); muscapaul.com (defunct; site owner)
  • Veteran Member, joined since
  • Contributed 1,075 posts on the community forums.
  • Started 8 threads in the forums
answered
Veteran Member

Thank you, I alerted the dev team to your post.
0 replies
— 3 months later —
S
starefossen
S
www.postexus.com - Follow Postexus on Facebook.
  • Senior Member, joined since
  • Contributed 359 posts on the community forums.
  • Started 20 threads in the forums
answered
Senior Member

Thank you for reporting this dfmurphy. Your changes has been added to PHPFusion v7.01!
0 replies
H
HobbyMan
H
Just some Guy
  • Veteran Member, joined since
  • Contributed 1,486 posts on the community forums.
  • Started 91 threads in the forums
answered
Veteran Member

Tried it on a live site with 3000+ records [60 per page], works fine, well done. B)
0 replies
C
crysun2007
C
crysun2007 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.
answered
Junior Member

i think i will study PHP language more hardly
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 4 posts
  • Votes 0 votes
  • Topic users 5 members

5 participants

M
M
Paul

Time flies like an arrow, fruit flies like banana (Groucho Marx)

Sites: Diptera.info (site owner); Online-Keys.net (site owner); Sciomyzidae.info (site co-owner); muscapaul.com (defunct; site owner)
  • Veteran Member, joined since
  • Contributed 1,075 posts on the community forums.
  • Started 8 threads in the forums
S
S
www.postexus.com - Follow Postexus on Facebook.
  • Senior Member, joined since
  • Contributed 359 posts on the community forums.
  • Started 20 threads in the forums
D
D
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 19 threads in the forums
  • Started this discussions
H
H
Just some Guy
  • Veteran Member, joined since
  • Contributed 1,486 posts on the community forums.
  • Started 91 threads in the forums
C
C
crysun2007 10
  • Junior Member, joined since
  • Contributed 16 posts on the community forums.

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet