PHP code example of aleswita / visualpaginator
1. Go to this page and download the library: Download aleswita/visualpaginator 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/ */
aleswita / visualpaginator example snippets
declare(strict_types = 1);
use AlesWita\VisualPaginator\VisualPaginator;
use AlesWita\VisualPaginator\VisualPaginatorFactory;
use Nette\Application\UI\Presenter;
final class HomePresenter extends Presenter
{
/** @inject */
public VisualPaginatorFactory $visualPaginatorFactory;
public function actionDefault(): void
{
$this['paginator']->setItemCount(1000);
$offset = $this['paginator']->getOffset();
$itemsPerPage = $this['paginator']->getItemsPerPage();
['SELECT * FROM `orders` LIMIT ? OFFSET ?', $itemsPerPage, $offset];
}
protected function createComponentPaginator(): VisualPaginator
{
$paginator = $this->visualPaginatorFactory->create();
$paginator->ajax = true;
$paginator->canSetItemsPerPage = true;
$paginator->templateFile = __DIR__ . '/my_awesome_template.latte';
return $paginator;
}
}