Acabo de hacer una pequeña prueba y no tuve que hacer muchos cambios, el DI:
Código PHP:
Ver original 'album-list' => 'Album\Controller\ListController'
),
'Album\Controller\ListController' => array ( 'albumTable' => 'Album\Model\DbTable\AlbumTable'
)
),
'Album\Model\DbTable\AlbumTable' => array ( 'config' => 'Zend\Db\Adapter\PdoMysql'
)
),
'Zend\Db\Adapter\PdoMysql' => array ( 'host' => 'localhost',
'username' => 'root',
'password' => 'mypwd',
'dbname' => 'test'
)
)
),
'Zend\View\PhpRenderer' => array( 'Album' => __DIR__ . '/../views',
),
),
),
),
'Zend\Mvc\Router\RouteStack' => array( 'type' => 'Zend\Mvc\Router\Http\Segment',
'route' => '/album[/:page]',
'page' => '[0-9]+',
),
'controller' => 'album-list',
'action' => 'index',
'page' => 1
),
),
),
),
),
),
),
),
Controlador:
Código PHP:
Ver originalpublic function indexAction()
{
$albums = $this->getAlbumTable()->fetchAll();
$matches = $this->getEvent()->getRouteMatch();
$nPage = $matches->getParam('page', 1);
PaginationControl::setDefaultViewPartial('paginator.phtml');
$paginator = Paginator::factory($albums);
$paginator->setDefaultItemCountPerPage(5);
$paginator->setCurrentPageNumber($nPage);
return array('albums' => $paginator); }
Vista:
Código PHP:
Ver original<h1>Albums</h1>
<ul>
<?php foreach ($this->albums as $album) { ?>
<li><?php echo $album->album_id; ?> - <?php echo $album->album; ?></li>
<?php } ?>
</ul>
<?php echo $this->paginationControl($this->albums, 'Sliding'); ?>
Paginador:
Código PHP:
Ver original<?php if ($this->pageCount): ?>
<div class="paginationControl">
<?php echo $this->firstItemNumber; ?> - <?php echo $this->lastItemNumber; ?>
de <?php echo $this->totalItemCount; ?>
<!-- First page link -->
<?php if (isset($this->previous)): ?> <a href="
<?php echo $this->url('album-list', array('page' => $this->first)); ?>">
Primero
</a> |
<?php else: ?>
<span class="disabled">First</span> |
<?php endif; ?>
<!-- Previous page link -->
<?php if (isset($this->previous)): ?> <a href="
<?php echo $this->url('album-list', array('page' => $this->previous)); ?>">
< Anterior
</a> |
<?php else: ?>
<span class="disabled">< Anterior</span> |
<?php endif; ?>
<!-- Next page link -->
<a href="
<?php echo $this->url('album-list', array('page' => $this->next)); ?>">
Siguiente >
</a> |
<?php else: ?>
<span class="disabled">Siguiente ></span> |
<?php endif; ?>
<!-- Last page link -->
<a href="
<?php echo $this->url('album-list', array('page' => $this->last)); ?>">
Último
</a>
<?php else: ?>
<span class="disabled">Último</span>
<?php endif; ?>
</div>
<?php endif; ?>