Today (September 24, 2009) I saw an improvement about Styling the paging feature created by nikos in Pods Discussion Forums. It was an interesting improvement, indeed. Then I applied it on one of my Pods powered websites. I also added the 2 additional links: Previous and Next on the pagination feature, by modifying the pagination_2.php and Pod.class.php file.
Again, please note that this modification only for the classical version; Pods 1.x.
-
Modified your \pods\core\pagination_2.php file become like this:
<style type="text/css">
/* Pod Paging
-------------------------------------------------------------- */
.podPager {padding:0.8em;overflow:hidden;border-top:1px solid #eee;background:#f6f6f6;color:#666;margin-bottom:0.8em;}
.pageNum {padding:0 5px;}
.currentPage {background:#ccc;color:#fff;}
</style>
<?php
$page = $this->page;
$rows_per_page = $this->rpp;
$total_rows = $this->getTotalRows();
$total_pages = ceil($total_rows / $rows_per_page);
$type = $this->datatype;
$request_uri = "?type=$type&";
foreach ($_GET as $key => $val)
{
if ('pg' != $key && 'type' != $key && !empty($val))
{
$request_uri .= $key . '=' . urlencode($val) . '&';
}
}
?>
<div class="podPager">
<?php
if($total_pages > 1) :
echo '<span class="pages">'.$label1.' '.$page.' '.$label2.' '.$total_pages.':</span>';
endif;
if (1 < $page) :
if($total_pages > 2) :
$prev = $page - 1;
echo ' <a href="'.$request_uri.'pg=1" class="prevPage">« '.$label3.' ... </a>';
echo ' <a href="'.$request_uri.'pg='.$prev.'" class="firstPage">« '.$label6.'</a>';
else :
echo ' <a href="'.$request_uri.'pg=1" class="pageNum firstPage">1</a>';
endif;
endif;
if (1 < ($page - 100)) :
echo ' <a href="'.$request_uri.'pg='.($page - 100).'" class="pageNum">'.($page - 100).'</a>';
endif;
if (1 < ($page - 10)) :
echo ' <a href="'.$request_uri.'pg='.($page - 10).'" class="pageNum">'.($page - 10).'</a>';
endif;
for ($i = 4; $i > 0; $i--) :
if (1 < ($page - $i)) :
echo ' <a href="'.$request_uri.'pg='.($page - $i).'" class="pageNum">'.($page - $i).'</a>';
endif;
endfor;
?> <span class="pageNum currentPage"><?php echo $page; ?></span><?php
for ($i = 1; $i < 5; $i++) :
if ($total_pages > ($page + $i)) :
echo ' <a href="'.$request_uri.'pg='.($page + $i).'" class="pageNum">'.($page + $i).'</a>';
endif;
endfor;
if ($total_pages > ($page + 10)) :
echo ' <a href="'.$request_uri.'pg='.($page + 10).'" class="pageNum">'.($page + 10).'</a>';
endif;
if ($total_pages > ($page + 100)) :
echo ' <a href="'.$request_uri.'pg='.($page + 100).'" class="pageNum">'.($page + 100).'</a>';
endif;
if ($page < $total_pages) :
if($total_pages > 2) :
$next = $page + 1;
echo ' <a href="'.$request_uri.'pg='.$next.'" class="nextPage">'.$label5.' »</a>';
echo ' <a href="'.$request_uri.'pg='.$total_pages.'" class="lastPage"> ... '.$label4.' »</a>';
else:
echo ' <a href="'.$request_uri.'pg='.$total_pages.'" class="pageNum">2</a>';
endif;
endif;
?>
</div> -
Open your \pods\core\Pods.class.php file, and find this code:
then replace it with the following code:
/*
==================================================
Display the pagination controls
==================================================
*/
//function getPagination($label = 'Go to page:')
function getPagination($label1 = 'Page', $label2 = 'of', $label3 = 'First', $label4 = 'Last', $label5 = 'Next', $label6 = 'Previous')
{
if ($this->rpp < $this->getTotalRows())
{
include realpath(dirname(__FILE__) . '/pagination_2.php');
}
}
/* -
To display the paging, I added to my template or in my PodPages:
<?php
// For example, this is for Indonesian language
echo $Record->getPagination('Halaman:', 'dari', 'Awal', 'Akhir', 'Maju', 'Mundur');
// For English (default):
echo $Record->getPagination();
?>
Hopefully you find it useful.