<?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) {
$b = "<div>(this" ." is page $page of $total_pages)</div>\n" . $b;
}
$b .= "<div><font size=\"2\"><b>page:</b> ";
for ($i = 1; $i <= $total_pages; $i++) {
if ($i == $page) {
$b .= "<b>$i</b>";
} else {
if ($i > 1) {
$b .= "<a href=\"$PHP_SELF?page=$i$a\">$i</a>";
} else {
$b .= "<a href=\"$PHP_SELF$a\">$i</a>";
}
}
if ($i < $total_pages) {
$b .= ", ";
}
}
$b .= "</font></div>\n";
}
return $b;
}
?>
Bonjour,
Yann, pourrais-tu m’indiquer quels CMS permettent de faire cette apgination ? Merci.