= $totalTwts) || ($paginateTwts == false) ) { // echo "Only " . $totalTwts . " so no need for pagnation. (max: ". $maxTwts . ")
"; $paginateTwts = false; } else { // echo "Over " . $maxTwts . " so pagnation is needed.
"; $paginateTwts = true; // for showing pagnation navigation below timeline $totalPages = ceil($totalTwts / $maxTwts); $currentPage = max(1, min($_GET["page"], $totalPages)); // Split up twts into pages $startingTwt = (($currentPage - 1) * $maxTwts); $twts = array_slice($twts, $startingTwt, $maxTwts); // Fingure out base URL for prev/next links $pageURL = $_SERVER['REQUEST_URI']; //echo $pageURL."
"; if (!empty($_GET['page'])) { if (preg_match('/\?page=/', $pageURL)) { //echo "cotains ?page= so reuse that
"; $pageURL = preg_replace('/\?page=\d*/', "", $pageURL) . '?page='; } if (preg_match('/&page=/', $pageURL)) { //echo "cotains &page= so reuse that
"; $pageURL = preg_replace('/&page=\d*/', "", $pageURL) . '&page='; } } else { if (!preg_match('/(\?|&)/', $pageURL)) { //echo "No param, so use ?page
"; $pageURL = $pageURL . '?page='; } if (!preg_match('/(\?|&)page/', $pageURL)) { //echo "other param than _page, so use &page
"; $pageURL = $pageURL . '&page='; } } }