Pagination function? #4642
-
Hey! Sorry it's me again with my stupid questions. Does e107 have a function for easy pagination by itself or do I have to squeeze it out of the news plugin somehow? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
It is currently not documented yet (work in progress!), but there is a public function for it: You can call it by using /**
* Render Pagination using 'nextprev' shortcode.
* @param string $url eg. e_REQUEST_SELF.'?from=[FROM]'
* @param int $total total records
* @param int $from value to replace [FROM] with in the URL
* @param int $perPage number of items per page
* @param array $options template, type, glyphs
* @return string
*/
public function pagination($url='', $total=0, $from=0, $perPage=10, $options=array())
{
...
} Alternatively, you can use the {NEXTPREV} shortcode directly. You can find more information on it in |
Beta Was this translation helpful? Give feedback.
-
This pagination example is for displaying data per pages not as records (page vs from). <?php
include_once('class2.php');
require_once(HEADERF);
$frm = e107::getForm();
$sql = e107::getDb();
$ns = e107::getRender();
$text = "";
$count = $sql->count('chatbox');
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$perPage = 10;
$from = ($page - 1) * $perPage;
$total = ceil($count / $perPage);
$options = array('type' => 'page', 'navcount' => 4);
$rows = $sql->retrieve("chatbox", "cb_id, cb_nick, cb_message","LIMIT ".$from.", ".$perPage."", true);
foreach($items as $item)
{
$text .= $item['cb_id'] ." - ".$item['cb_nick'].": ".$item['cb_message']."<br>";
}
$text = $frm->pagination(e_REQUEST_SELF.'?page=[FROM]', $total, $page, $perPage, $options);
$ns->tablerender("Pagination Test", $text);
require_once(FOOTERF);
?> |
Beta Was this translation helpful? Give feedback.
This pagination example is for displaying data per pages not as records (page vs from).