I'm having issues with Zend Framework 2 Router object. I'm trying to implement Zend\Paginator
into the quickstart routing mechanism example without success. Let me explain:
After following the quickstart I ended with something like this:
'album' => array(
'type' => 'Segment',
'options' => array(
'route' => '/album[/:action][/:id]',
'constraints' => array(
'action' => '[a-z][a-z0-9\-]*',
'id' => '[0-9]+'
),
'defaults' => array(
'controller' => 'Album',
'action' => 'index'
)
)
)
The problem arises when I tried to implement a paginator for my browse/index page. Giving that I need a router like /album[/:action][/:id][/:page]
that doesn't work because the router assigns :page
var to :id
. I removed the :id
section ending with something like /album[/:action][/:page]
and invoking in my add/edit action
$matches = $this->getEvent()->getRouteMatch();
$id = $matches->getParam('page');
working without problems but I like things keep mnemonic. So my question is: Is it possible to achieve this without creating a duplicate router only for the paginator to look like I like? an I doing something incorrect?