Geek out with my wang out
2003-05-22 10:21:34 ET

So I've finished the page index engine, which is quite a bit more complicated than it seems.

The page index engine displays the text at the bottom of a bme-type page, such as "Diary Page: 1 2 3 4 5 6 7 8 9 -- 101 (next)", with all the appropriate links.

It takes the number of entires, divides it by the entries-per page, and plugs into the gallery/journal/whatever engine as a function call. It has to be generated dynamically, based upon what page you're currently on.

The complicated part stems from taking into account all the possibilites. What if there're less than 7 total pages, what if the start page is less than 3, how do you decide where the middle is in a non-even number of possible pages, making sure there is a first page and last page, and a previous and next button.

The math is kind of complex, and I'm sure I missed a few ways to make it easier. Nonetheless, it's still somewhat involved.

$i = 0;
        while ($i < 3) {<BR>
            if ($postOptions <= $options) {<BR>
                echo "[a hrof=testpage.php?page=$postOptions>$postOptions[/a]";
            }
            if ($i != 2 && $options >= ($postOptions ) ) {
                echo ":";
            } 
            $i++;
            $postOptions++;
        }

There's a snippet. Here's the demonstration page. The test case is with 40 possible pages.


2003-05-22 10:37:51 ET

listen, i looked and came up with this hot pic of you

2003-05-22 10:39:29 ET

okay, i'm losing my mind, please ignore me completely

  Return to shadeland's page