First the code we will write in Controller or Symfony module Action class.
public function executePaging(sfWebRequest $request){
$results_per_page=10;
$set_first_page=1;
$this->pagination = new sfDoctrinePager('User', $results_per_page);
$this->pagination->setQuery(Doctrine::getTable('User')->createQuery('u'));
$this->pagination->setPage($request->getParameter('page', $set_first_page));
$this->pagination->init();
}
now the code we write in View or the ethodNameSuccess in our case PagingSuccess.php| <?php echo $users->getId(); ?> | <?php echo $users->getFirstName(); ?> | <?php echo $users->getLastName(); ?> | <?php echo $users->getEmail(); ?> |
<?php echo link_to('<<', 'myModule/Paging?page='.$pagination->getFirstPage()) ?>
<?php if ($pagination->haveToPaginate()): ?>
<?php $links = $pagination->getLinks(); foreach ($links as $page): ?>
<?php echo ($page == $pagination->getPage()) ? $page : link_to($page, 'myModule/Paging?page='.$page) ?>
<?php endforeach ?>
<?php endif ?>
<?php echo link_to('>>', 'myModule/Paging?page='.$pagination->getLastPage()) ?>
try to implement it and you will see its very easy :)
1 comments:
Good
Post a Comment