Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Nawigator
^piraciq^
post
Post #1





Grupa: Zarejestrowani
Postów: 25
Pomógł: 0
Dołączył: 1.02.2003
Skąd: Kraków

Ostrzeżenie: (0%)
-----


Witam Wielkie Zgromadzenie (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

mam taka sprawe jak widac w tytule chodzi mi o nawigatora na strone tak jak jest tu na forum na dole z podzialem na strony by bylo widac pirwsza strone ostatnia i piec kolejnych lub dziesiec. klikam na 5 dajmy na to strone i w nawigatorze widac

Pierwsza strona 5 6 7 8 9 10 ostatnia strona cos w tym stylu

z góry dziekuje za pomoc
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
MStaniszczak
post
Post #2





Grupa: Zarejestrowani
Postów: 71
Pomógł: 1
Dołączył: 3.10.2004

Ostrzeżenie: (0%)
-----


Witam

Ja kiedyś napisałem sobie taką klasę – działała, ale dziś już mam to inaczej napisane. W każdym razie może się przyda;-) Nowej klasy nie dam, ale może sobie tą ktoś przerobi;-) Jak się przyda to fajno jak nie to też. A jak używać chyba widać;-)

  1. <?php
  2. if (eregi(&#092;"class.pagesMenu.inc.php\",$_SERVER['PHP_SELF'])) {
  3. Header(&#092;"Location: ../index.php\");
  4. die();
  5. }
  6.  
  7. class cPagesMenu {
  8. var $current;
  9. var $max;
  10.  
  11. var $jumpSize;
  12.  
  13. var $numbersTable;
  14.  
  15. var $next;
  16. var $back;
  17.  
  18. function cPagesMenu($from, $max, $jump) {
  19. $this->current = ceil($from/$jump)+1;
  20. $this->max = ceil($max/$jump);
  21. $this->jumpSize = $jump;
  22.  
  23. if($from<0)
  24. $form = 0;
  25.  
  26. if($from>$max)
  27. $from = $max-$jump;
  28.  
  29. if($this->current<=3) {
  30. $to = $this->max;
  31. if($this->max>=7)
  32. $to = 7;
  33.  
  34. for($count = 1; $count<=$to; $count++) {
  35. if($count == $this->current)
  36. $tmp = array('Number' => $count, 'Current' => true);
  37. else
  38. $tmp = array('Number' => $count, 'Current' => false, 'From' => ($count-1)*$jump);
  39.  
  40. $this->numbersTable[$count-1] = $tmp;
  41. }
  42.  
  43. if($this->current > 1)
  44. $this->back = true;
  45. else
  46. $this->back = false;
  47.  
  48. if($this->current < $this->max)
  49. $this->next = true;
  50. else
  51. $this->next = false;
  52. } elseif($this->current<=($this->max-3) && ($this->current>3)) {
  53. for($count = $this->current-3, $index = 0; $count<=$this->current+3; $count++, $index++) {
  54. if($count == $this->current)
  55. $tmp = array('Number' => $count, 'Current' => true);
  56. else
  57. $tmp = array('Number' => $count, 'Current' => false, 'From' => ($count-1)*$jump);
  58.  
  59. $this->numbersTable[$index] = $tmp;
  60. }
  61.  
  62. if($this->current > 1) 
  63. $this->back = true; 
  64. else
  65. $this->back = false;
  66.  
  67. if($this->current < $this->max)
  68. $this->next = true;
  69. else
  70. $this->next = false;
  71. } elseif($this->current>($this->max-3)) {
  72. if($this->max > 7)
  73. $fr = $this->max-6;
  74. else
  75. $fr = $this->max-($this->max-1);
  76.  
  77.  
  78. for($count = $fr, $index = 0; $count<=$this->max; $count++, $index++) {
  79. if($count == $this->current)
  80. $tmp = array('Number' => $count, 'Current' => true);
  81. else
  82. $tmp = array('Number' => $count, 'Current' => false, 'From' => ($count-1)*$jump);
  83.  
  84. $this->numbersTable[$index] = $tmp;
  85. }
  86.  
  87. if($this->max-$this->current >= 0)
  88. $this->back = true;
  89. else
  90. $this->back = false;
  91.  
  92. if($this->current<$this->max)
  93. $this->next = true;
  94. else
  95. $this->next = false;
  96. }
  97. }
  98.  
  99. function getNumbers() {
  100. return $this->numbersTable;
  101. }
  102.  
  103. function getCurrent() {
  104. return $this->current;
  105. }
  106.  
  107. function getNext() {
  108. if($this->next)
  109. return (($this->current-1)*$this->jumpSize)+$this->jumpSize;
  110. else 
  111. return false;
  112. }
  113.  
  114. function getBack() {
  115. if($this->back)
  116. return (($this->current-1)*$this->jumpSize)-$this->jumpSize;
  117. else
  118. return false;
  119. }
  120. }
  121. ?>

Pozdrawiam
Marcin Staniszczak
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 14.10.2025 - 22:17