views:

39

answers:

1

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

    </div>
    <p class="clear"></p>
</div>
A: 

Try providing a default value of 1 for :page in the router

http://framework.zend.com/manual/en/zend.controller.router.html#zend.controller.router.routes.standard (scroll down to Variable Defaults)

$router->addRoute('studios/page',   
    new Zend_Controller_Router_Route(':id/studio/:page',
          array('module' => 'default', 'controller' => 'studio', 'action' => 'view'),
          array('page' => 1)));
Steve
Thanks for the advice, however this doesn't make any difference, its still not appending the page.
azz0r
ok. i don't think i quite understood your question: the first sentence or two didn't quite make sense, so I took a guess at what i thought you meant (grin). Can you clarify a little?
Steve
Using that as a url rule, if I come in via alpha/studio the paging on that page links directly back to that page and does not link to alpha/studio/1 alpha/studio/2 like you'd expect :s
azz0r
mmm... yeah, but you don't need the /1so the main urls would be/alpha/studio (page 1)/alpha/studio/2 (page 2)/alpha/studio/3 (page 3)etc
Steve
Its not about the first page not working. Its about zend_paginator not linking to other pages when you land on alpha/studio, clicking page 2 won't take you to alpha/studio/2 it will link to alpha/studio.
azz0r