Zend_Paginator: page number on links on the page without the page number specified by the URL

Without sticking / 1 to the url to change the Zend_Paginator to get closer to the url? The user is currently navigating to / aaron / studio. Then the user should click the paging and start accessing the URLs, for example: / 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, Paginator will link to other pages correctly, if I goto / aaron / studio does not link to other pages, but only on the page.

What I need is one way or another so that Paginator finds out about its location even without a page in the url.

Here is 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, I see my opinion on request:

<?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 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>
        &nbsp; Page <?php echo $this->current; ?> of <?php echo $this->last; ?>
        </p>

    </div>
    <p class="clear"></p>
</div>
+3
2

, , . :

$router->addRoute(
'projects',
    new Zend_Controller_Router_Route('/:lang/projects/:category/', 
        array('lang' => 'en',
           'module' => 'index',
           'controller' =>'projects',
           'action' =>'index'
        )
    )
);

paginator , : page var paginator. :

$router->addRoute(
'projects',
    new Zend_Controller_Router_Route('/:lang/projects/:category/:page', 
        array('lang' => 'en',
           'module' => 'index',
           'controller' =>'projects',
           'action' =>'index',
               'page'   => 1
        )
    )
);
+2

: 1

http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.standard ( )

$router->addRoute('studios/page',   
    new Zend_Controller_Router_Route(':id/studio/:page',
          array('module' => 'default', 'controller' => 'studio', 'action' => 'view'),
          array('page' => 1)));
0

Source: https://habr.com/ru/post/1757187/


All Articles