dajare

Pager helper

Jan 25th, 2010
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.06 KB | None | 0 0
  1. <?php use_helper('Pager');
  2. $pager = new Pager(array( 'style' => 'classic', 'items_per_page' => 3, 'total_items' => $this->childrenCount())); ?>
  3. <?php // $last_articles = $this->children(array('limit'=>5, 'order'=>'page.created_on DESC')); ?>
  4.  
  5. <?php $last_articles = $this->children(array('limit' => $pager->items_per_page, 'offset' => $pager->sql_offset, 'order'=>'page.created_on DESC')); ?>
  6.  
  7. <?php foreach ($last_articles as $article): ?>
  8. <div class="entry">
  9.   <h3><?php echo $article->link($article->title); ?></h3>
  10.  
  11. <?php if (($more_pos = strpos($article->content(), '<!--more-->')) === false ) {
  12.   // "more" trigger NOT found, so just echo content
  13.   echo $article->content();
  14. } else {
  15.   // "more" trigger IS found, so echo only teaser and add link to whole article
  16.   echo substr($article->content(), 0, $more_pos);
  17.   echo '</p><p>'. $article->link('Read more...') .'</p>';
  18. } ?>
  19.  
  20.   <p class="info">Posted: <?php echo $article->date(); ?> | Tags: <?php echo tag_links($article->tags()); ?></p>
  21.  
  22.   </p>
  23. </div>
  24. <?php endforeach; ?>
  25.  
  26. <?php echo $pager; ?>
Add Comment
Please, Sign In to add comment