Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Zend_Paginator simple usage*/
- $model = new Application_Model_Test(); //Нужная модель
- $data = $model->getAdapter()->query("SELECT * FROM test")->fetchAll(); //выгребаем ВСЕ, надо оптимизировать
- $page = $this->_getParam('page', 1); //номер страницы
- $paginator = Zend_Paginator::factory($data); //фабрикуем пагинатор
- $paginator->setItemCountPerPage(3); //количество материалов на странице (в админку?)
- $paginator->setCurrentPageNumber($page); //текущая страница
- $this->view->paginator = $paginator; //передали во вью
- /*Скрипт вида для pagination partial*/
- <?php if ($this->pageCount): ?>
- <div id="paginationControl">
- <!-- Ссылка на предыдущую страницу -->
- <?php if (isset($this->previous)): ?>
- <a href="<?= $this->url(array('page' => $this->previous)); ?>">< Previous</a> |
- <?php else: ?>
- <span class="disabled">< Previous</span> |
- <?php endif; ?>
- <!-- Нумерованные ссылки на страницы -->
- <?php foreach ($this->pagesInRange as $page): ?>
- <?php if ($page != $this->current): ?>
- <a href="<?= $this->url(array('page' => $page)); ?>"><?= $page; ?></a> |
- <?php else: ?>
- <?= $page; ?> |
- <?php endif; ?>
- <?php endforeach; ?>
- <!-- Ссылка на следующую страницу -->
- <?php if (isset($this->next)): ?>
- <a href="<?= $this->url(array('page' => $this->next)); ?>">Next ></a>
- <?php else: ?>
- <span class="disabled">Next ></span>
- <?php endif; ?>
- </div>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement