Hello,
Without sticking /1 onto a url is there away to change Zend_Paginator to approach a URL? Currently the user goes to /aaron/studio. Then the user should click through the paging and start accessing URLS such as : /aaron/studio/2
I have this rule:
$router->addRoute('studios/page', new Zend_Controller_Router_Route(':id/studio/:page',array('module' => 'default', 'controller' => 'studio', 'action' => 'view')));
If I go-to /aaron/studio/2, the Paginator links correctly to other pages, if i goto /aaron/studio it doesn't link to other pages, just the page its on.
What I need todo somehow it make Paginator aware that of its location even without a page in the URL.
Heres my controller code if it helps:
$page = $this->_getParam('page', 1);
$from = ($page * $this->clips_per_page) - $this->clips_per_page;
$count = Model_Clip::load_by_type(array('type' => 'studio_id', 'values' => $object->id, 'to' => 0, 'to' => COUNT_HIGH, 'count' => 1, 'order' => 'd.views DESC'));
$paginator = Zend_Paginator::factory($count);
$paginator->setItemCountPerPage($this->clips_per_page);
$paginator->setCurrentPageNumber($page);
$paginator->setPageRange(25);
$this->view->paginator = $paginator;
Edit, heres my view as requested:
<?php if (count($this->paginator) && $this->paginator->count() > 1): ?>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'pagination.phtml', array('translate' => $this->translate)); ?>
<?php endif; ?>
and the partial
<div class="pagination-control" style="width: auto; text-align: center; margin: 0 auto">
<div style="width: auto;">
<!-- First page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url(array('page' => $this->first)); ?>">Start</a> |
<?php else: ?>
<!-- <span class="disabled">Start |</span> -->
<?php endif; ?>
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<a href="<?php echo $this->url(array('page' => $this->previous)); ?>"> Previous</a> |
<?php else: ?>
<!-- <span class="disabled"> Previous |</span> -->
<?php endif; ?>
<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<a href="<?php echo $this->url(array('page' => $page)); ?>"><?php echo $page; ?></a>
<?php else: ?>
<span class="chosen"><?php echo $page; ?></span>
<?php endif; ?>
<?php endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
| <a href="<?php echo $this->url(array('page' => $this->next)); ?>">Next </a> |
<?php else: ?>
<!-- <span class="disabled">| Next |</span> -->
<?php endif; ?>
<!-- Last page link -->
<?php if (isset($this->next)): ?>
<a href="<?php echo $this->url(array('page' => $this->last)); ?>">End</a>
<?php else: ?>
<!-- <span class="disabled">End</span> -->
<?php endif; ?>
<p>
Page <?php echo $this->current; ?> of <?php echo $this->last; ?>
</p>
</div>
<p class="clear"></p>
</div>