Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (action)
- public function listAction()
- {
- $page = (int) $this->params()->fromRoute('id', 0);
- $posts = $this->getPagesTable()->selectPages();
- $paginator = new Paginator(new PaginatorIterator($posts));
- $paginator->setCurrentPageNumber($page)
- ->setItemCountPerPage(2)
- ->setPageRange(7);
- return new ViewModel(array(
- 'paginator' => $paginator,
- ));
- }
- (view)
- <?php foreach ($paginator as $post) : ?>
- <h2><?php echo $this->escapeHtml($post->id); ?></h2>
- <div><?php echo $this->escapeHtml($post->name);?>
- <?php endforeach; ?>
- public function listAction()
- {
- $page = (int) $this->params()->fromRoute('id', 0);
- $posts = $this->getPagesTable()->selectPages();
- $paginator = new Paginator(new PaginatorIterator($posts));
- $paginator->setCurrentPageNumber($page)
- ->setItemCountPerPage(2)
- ->setPageRange(7);
- foreach ($paginator as $post) {
- // some code or empty foreach
- };
- return new ViewModel(array(
- 'paginator' => $paginator,
- ));
- }
- i am using iterator_to_array($userList);
Add Comment
Please, Sign In to add comment