I am trying to create pagination on my news feed. I have two modes in my news feed: all news feed and feed by category. Pagination for all news feed works fine, but I have problems with "feed by category" pagination.
I use paginationControl like this:
<?=$this->paginationControl(
$this->news,
'Sliding',
'pagination_control',
array('route' => 'news/category')
)?>
Route news/category
config:
'category' => array(
'type' => 'Segment',
'options' => array(
'route' => '/:category[/page-:page]',
'constraints' => array(
'category' => '[a-z]+',
'page' => '[1-9][0-9]*',
),
'defaults' => array(
'controller' => 'News\Controller\Item',
'action' => 'category',
'page' => 1,
)
),
'may_terminate' => true,
),
So I need to specify parameter category. I am trying this:
<?=$this->paginationControl(
$this->news,
'Sliding',
'pagination_control',
array('route' => 'news/category', array('category' => $this->category->getUrl()))
)?>
But I am getting error "Missing parameter ...":
Looks like it is impossible to set parameter through paginationControl.
How to specify route with parameter in paginationControl correctly?
Update 1
My paginationControl view looks like:
<?php if ($this->pageCount > 1): ?>
<div>
<ul class="pagination pagination-sm">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<li>
<a href="<?=$this->url($this->route, array('page' => $this->previous))?>">
«
</a>
</li>
<? else: ?>
<li class="disabled"><span>«</span></li>
<? endif; ?>
<!-- Numbered page links -->
<? foreach ($this->pagesInRange as $page): ?>
<? if ($page != $this->current): ?>
<li>
<a href="<?=$this->url($this->route, array('page' => $page))?>">
<?=$page?>
</a>
</li>
<? else: ?>
<li class="active"><span><?=$page?></span></li>
<? endif; ?>
<? endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<li>
<a href="<?=$this->url($this->route, array('page' => $this->next))?>">
»
</a>
</li>
<?php else: ?>
<li class="disabled"><span>»</span></li>
<?php endif; ?>
</ul>
</div>
<div>
<span class="small grey"><?="Страница ".$this->current." из ".$this->pageCount?></span>
</div>
<?php endif; ?>