PHP code example of jsnlib / joomla_pagination
1. Go to this page and download the library: Download jsnlib/joomla_pagination library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jsnlib / joomla_pagination example snippets
$pagination = new \Jsnlib\Joomla\Pagination($this);
$pagination
// 每頁多少筆
->limit(10)
// 每頁起始值
->offset(0)
// 未分頁的總數量
->total(100)
// 建立
->create(function ($joomla, $param)
{
// 返回分頁的數據列表
return $joomla->model->getAll(new \Jsnlib\Ao
([
'offset' => $param->offset,
'limit' => $param->limit
]));
});
$pagination->limit(function ()
{
// do something ......
return 5;
})
class TodoListControllerTodoList extends JControllerLegacy
{
public function index()
{
$pagination = new \Jsnlib\Joomla\Pagination($this);
$view = $this->getView('TodoList', 'html');
$view->setLayout('main');
$view->pagination = $pagination
// 每頁多少筆
->limit(10)
// 每頁起始值
->offset($this->post->getInt('limitstart', 0))
// 未分頁的總數量
->total(function ($joomla)
{
return $joomla->something_model->getNumAllFilter();
})
// 建立
->create(function ($joomla, $param)
{
// 返回分頁的數據列表
return $joomla->something_model->getAllFilter(new \Jsnlib\Ao
([
'offset' => $param->offset,
'limit' => $param->limit
]));
});
$view->main();
}
}
foreach ($this->pagination->collection as $key => $something):
<?=$this->pagination->joomlaPagination->getListFooter();
<input type="hidden" name="option" value="務必正確設定如 com_news">
<input type="hidden" name="task" value="務必正確設定如 new.index">