how can show a limiter on the pagination for a custom collection?
for example a select (options) with [5=>5, 10=> 10, 50=> 50]
I checked vendor/magento/module-theme/view/frontend/templates/html/pager.phtml
So, I put this code in the block
protected function _prepareLayout()
{
$collection = $this->_faqFactory->create()->getCollection();
parent::_prepareLayout();
if ($collection) {
// create pager block for collection
$pager = $this->getLayout()->createBlock('Magento\Theme\Block\Html\Pager','my.custom.pager');
// // assign collection to pager
$pager->setLimit(10)->setCollection($collection);
$pager->setAvailableLimit([10=>10,20=>20,50=>50,100=>100]);
$this->setChild('pager', $pager);// set pager block in layout
}
return $this;
}
/**
* @return string
*/
// method for get pager html
public function getPagerHtml()
{
return $this->getChildHtml('pager');
}
in the template
<?php if ($block->getPagerHtml()): ?>
<div class="toolbar bottom"><?php echo $block->getPagerHtml(); ?></div>
<?php endif ?>
but only see the pagination, not the limiter
Looks like your code is right.
Use Xdebug to debug the template.
Hello Jorbel ,
Did you get the solution ??
Please help I have the same issue.
Because .limiter is set display: none; so you can solution by code:
.pages {
display: inline !important;
}
.limiter {
display: block !important;
}