Отсюда нужна получить $maxPages. Как разьделить данные?
<?php
// variables
$pagesPadding = 3; //Art jan you can also change this variable,this is the amount of numbers near the current page from both side
//functions
function showPages($currentPageNum, $padding, $maxPages) {
// show first age
if ($currentPageNum == 1) {
?> <span> <?php echo "1"; ?> </span> <?
} else {
?>
<span>
<a href="dramy/">
<?php echo "1";?>
</a>
</span>
<?
}
// SHOW NUMBERS
// check the necessity for empty part in the beginning
if ($currentPageNum-$padding <= 2) {
for($k = 2; $k <= $currentPageNum + $padding; $k++) {
if ( $k && $k == $currentPageNum ) {
// show only number without link
?> <span> <?php echo $k; ?> </span> <?php
} else {
// otherwise show number with link to that page
?>
<span>
<a href="dramy/?page=<?php echo $k; ?>">
<?php echo $k;?>
</a>
</span>
<?php
}
}
echo "<span> .. </span>";
// check the necessity for empty part in the end
} elseif($currentPageNum+$padding >= $maxPages-1) {
echo "<span> .. </span>";
for($k = $currentPageNum-$padding; $k <= $maxPages-1; $k++) {
if ( $k && $k == $currentPageNum ) {
// show only number without link
?> <span> <?php echo $k; ?> </span> <?php
} else {
// otherwise show number with link to that page
?>
<span>
<a href="dramy/?page=<?php echo $k; ?>">
<?php echo $k;?>
</a>
</span>
<?php
}
}
}
else
{
// in this case we must show empty part at both side
echo "<span> .. </span>";
for($k = $currentPageNum-$padding; $k <= $currentPageNum + $padding; $k++) {
if ( $k && $k == $currentPageNum ) {
// show only number without link
?> <span> <?php echo $k;?> </span> <?php
} else {
// otherwise show number with link to that page
?>
<span>
<a href="dramy/?page=<?php echo $k; ?>">
<?php echo $k;?>
</a>
</span>
<?php
}
}
echo "<span> .. </span>";
}
// show last page
if ($currentPageNum == $maxPages) {
?> <span> <?php echo $maxPages; ?> </span> <?
} else {
?>
<span>
<a href="dramy/?page=<?=$maxPages?>">
<?php echo $maxPages;?>
</a>
</span>
<?
}
}
?>
<div id="pagination">
<div id="pagination_numbers">
<?php
if ( isset($_GET['page']) ) { $currentPage = $_GET['page']; }
else { $currentPage = 1; }
// show pointers directed to left
if ( $currentPage != 1) {
?>
<span>
<a href="dramy/?page=<?php echo $currentPage-1; ?>"> << </a>
</span>
<?php
}
showPages($currentPage, $pagesPadding, $pages);
// show pointer directed to right
if ( $currentPage != $pages) {
?>
<span>
<a href="dramy/?page=<?php echo $currentPage+1; ?>"> >> </a>
</span>
<?php
}
?>
</div>
</div>
<script src="js/jquery.min.js"> </script>
<script type="text/javascript">
// ALIGNING PAGIANTION IN THE CENTER VIA FLOAT:LEFT PROPERTY
$(document).ready(function() {
// PAGINATION ALIGNING
var externalDiv = $("#pagination").css("width");
var internalDiv = $("#pagination_numbers").css("width");
var exLen = externalDiv.length;
var inLen = internalDiv.length;
var exDiv = externalDiv.substr(0,exLen-2);
var inDiv = internalDiv.substr(0,inLen-2);
var paginWidth = Math.round((exDiv - inDiv)/2);
$("#pagination_numbers").css({ marginLeftaginWidth+"px" });
});
</script>