1. Go to this page and download the library: Download surda/items-per-page 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/ */
surda / items-per-page example snippets
use Surda\ItemsPerPage\TItemsPerPage;
use Surda\ItemsPerPage\ItemsPerPageControl;
class ProductPresenter extends Nette\Application\UI\Presenter
{
use TItemsPerPage;
public function actionDefault(): void
{
/** @var ItemsPerPageControl $ipp */
$ipp = $this->getComponent('ipp');
$itemsPerPage = $ipp->getValue();
}
}
use Surda\ItemsPerPage\ItemsPerPageControl;
use Surda\ItemsPerPage\ItemsPerPageFactory;
class ProductPresenter extends Nette\Application\UI\Presenter
{
/** @var ItemsPerPageFactory */
private $itemsPerPageFactory;
/**
* @param ItemsPerPageFactory $itemsPerPageFactory
*/
public function injectItemsPerPageFactory(ItemsPerPageFactory $itemsPerPageFactory): void
{
$this->itemsPerPageFactory = $itemsPerPageFactory;
}
public function actionDefault(): void
{
/** @var ItemsPerPageControl $ipp */
$ipp = $this->getComponent('ipp');
$itemsPerPage = $ipp->getValue();
}
/**
* @return ItemsPerPageControl
*/
protected function createComponentIpp(): ItemsPerPageControl
{
// Init items per page component
$control = $this->itemsPerPageFactory->create();
// Define event
$control->onChange[] = function (ItemsPerPageControl $control, int $value): void {
// ...
};
return $control;
}
}
class ProductPresenter extends Nette\Application\UI\Presenter
{
/**
* @return ItemsPerPageControl
*/
protected function createComponentIpp(): ItemsPerPageControl
{
// Init items per page component
$control = $this->itemsPerPageFactory->create();
// list of allowed values
$control->setListOfValues([20, 50, 100]);
// Default items per page
$control->setDefaultValue(20);
// Value of items per page
$control->setValue(20);
// To use your own template
$control->setTemplateFile('path/to/your/latte/file.latte');
// Enable ajax (defult is enabled)
$control->enableAjax();
// Disable ajax
$control->disableAjax();
return $control;
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.