I’m in-choate

I think I may have beated my record for worst pun yet wiht that title. Anyhow, a big […]

I think I may have beated my record for worst pun yet wiht that title. Anyhow, a big shout to Brad Choate whose pagination script made life better at B&A, but whose personal IM tech support made the code far more usable through the addition of next and previous. (as seen here Boxes and Arrows: Making emotional connections through participatory design)

all you MT heads, here is the B&A code.


I put this in the head. brad says it should be in a external file called somethign .php and required.

<!–pagination code
<?php
function bloggerPagedBody($b,$a=”) {
// $b is the body of content to output
// $a is a defined anchor
global $HTTP_GET_VARS;
global $PHP_SELF;
$page = 1; // default page
if ($HTTP_GET_VARS[‘page’]) {
// page # is specified
$page = $HTTP_GET_VARS[‘page’];
}
// split content into an array of pages
// note: preg_split requires the Perl-compatible regex
// extension for PHP. If you don’t have this installed,
// you can do something similar with the PHP split function.
// I chose preg_split because I wanted a case-insensitive
// token to split pages.
$paged_body = preg_split("/<pb *\/>/i", $b);
$total_pages = count($paged_body);
// if requested page is out of the bounds of our
// paged content, default to displaying page 1
if (($page > $total_pages) || ($page < 1)) {
$page = 1;
}
// select the proper page of content
$b = $paged_body[$page-1];
// format the anchor if one was specified
if ($a) {
$a = "#$a";
}
// if more than 1 page was in the content,
// format output to show which page we are looking
// at (unless we’re looking at page 1) and also
// display a mini-navbar for the other available pages.
if ($total_pages > 1) {
if ($page > 1) {
$page_loc = "<div class=\"page\" style=\"float: left\">(this
is page
$page of $total_pages)</div>\n";
}
$page_nav = "<div class=\"page\" align=\"right\">";

if ($page > 1)
$page_nav .= "<a href=\"$PHP_SELF?page=".($page-1)."$a\"
class=\"pagecount\">Previous</a> &nbsp; ";

$page_nav .= "<span class=\"pagecount\">Page</span>
";

for ($i = 1; $i <= $total_pages; $i++) {
if ($i == $page) {
$page_nav .= "<b>$i</b>";
} else {
if ($i > 1) {
$page_nav .= "<a href=\"$PHP_SELF?page=$i$a\" class=\"pagecount\">$i</a>";
} else {
$page_nav .= "<a href=\"$PHP_SELF$a\" class=\"pagecount\">$i</a>";
}
}
if ($i < $total_pages) {
$page_nav .= ", ";
}
}
if ($page < $total_pages)
$page_nav .= " &nbsp; <a href=\"$PHP_SELF?page=".($page+1)."$a\"
class=\"pagecount\">Next</a>";
$page_nav .= "</div>\n";

// place page navigation at the top and bottom:
$b = $page_loc . $page_nav . $b . $page_nav;
}
return $b;
}
?>
–>

then this replaces MTbody and MTmore.

<!–pagination starts here–>
<?php
$entry = "<$MTEntryBody encode_php="qq"$>";
$more = "<$MTEntryMore encode_php="qq"$>";
$anchor = "<a name=\"more\"></a>\n";
// only display the main entry text if we’re looking at the first page.
if (!$HTTP_GET_VARS[‘page’] || $HTTP_GET_VARS[‘page’] == 1) {
echo bloggerPagedBody($entry . $anchor . $more);
} else {
echo bloggerPagedBody($anchor . $more);
}
?>
<!–pagination code ends here–>

enjoy.