Propel pager in symfony


stáhnout snippet
zobrazení: SyntaxHighlighter | GeSHi | Holý text
app.yml:
--------
all:
  listing:
    items:      15

actions.class.php:
------------------
      $c = new Criteria();
      $c->addDescendingOrderByColumn(SnippetPeer::CREATED_AT);

      $pager = new sfPropelPager('Snippet', sfConfig::get('app_listing_items', 10));
      $pager->setCriteria($c);
      $pager->setPage($this->getRequestParameter('page', 1));
      $pager->init();
      $this->pager = $pager;

listSuccess.php:
----------------
<?php include_partial('snippet/partialPager', array('pager' => $pager, 'paging' => 'snippet/list')); ?>

_partialPager.php
-----------------
<div class="pager">
  <?php if ($pager->haveToPaginate()): ?>
    <strong><?php echo link_to('« předchozí', $paging.'?'.$params.'&page='.$pager->getPreviousPage()) ?></strong>
    <?php $links = $pager->getLinks(5); foreach ($links as $page): ?>
      <?php echo ($page == $pager->getPage()) ? '<span>'.$page.'</span>' : link_to($page, $paging.'?'.$params.'&page='.$page) ?>
      <?php if ($page != $pager->getCurrentMaxLink()): ?><?php endif ?>
    <?php endforeach ?>
    <strong><?php echo link_to('další »', $paging.'?'.$params.'&page='.$pager->getNextPage()) ?></strong>
  <?php endif ?>
</div>

main.css
--------
/*
 * Pager
 * -----
 */
.pager {
    float: left;
	margin: 10px;
	margin-bottom: 15px;
	padding: 3px;
	font-family: arial;
	font-size: 100%;
	text-align: right;
}
 .pager a, .pager span {
    display: block;
    float: left;
    padding: 0.2em 0.5em;
    margin-right: 0.1em;
    border: 1px solid #fff;
    background: #fff;
}
.pager span {
  font-weight: bold;
}
.pager a {
    border: 1px solid #9AAFE5;
    text-decoration: none;
}
.pager a:hover {
    border-color: #2E6AB1;
    color: black;
}


Tagy:
php 68 řádků | 2008-02-04 20:39:29 | air.kadlec@seznam.cz