Advertisement
dajare

Pagination helper

Dec 3rd, 2009
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2. use_helper('Pagination');
  3. $pagination = new Pagination(array(
  4.  'base_url' => URI_PUBLIC.'articles',
  5.  'total_rows' => $this->childrenCount(),
  6.  'per_page' => 3, // should be the same number as the "limit" four lines below...
  7.  'num_links' => 8, // sets number of links adjacent to current page before adding first/last links
  8.  'cur_page' => (isset($_GET['page']) ? $_GET['page']: 1)
  9. ));
  10.  $last_articles = $this->children(array('limit'=>3, 'order'=>'page.created_on DESC')); ?>
  11.  
  12. <?php foreach ($last_articles as $article): ?>
  13.  
  14. <div class="entry">
  15.   <h3><?php echo $article->link($article->title); ?></h3>
  16.  
  17.   <?php echo implode('. ',array_slice(explode('.',$article->content()),0,1)).'. …'; ?>
  18.  
  19. <p class="info"><em>Posted by</em> <?php echo $article->author(); ?>
  20. <?php echo $article->date('at %I:%M %p on %a, %d %b %Y'); ?>.
  21.  
  22. <?php if($article->comment_status != 0): ?>
  23.      — <?php echo $num_comments = comments_count($article); ?> comment<?php if ($num_comments != 1) { echo 's'; } ?>
  24. <?php endif; ?>
  25.      <em>tags:</em>
  26.  
  27. <?php $i = 1; foreach($article->tags() as $tag){ ?>
  28.     <a href="<?php echo BASE_URL . 'tags/' . $tag . URL_SUFFIX; ?>"><?php echo $tag; ?></a><?php echo $i == count($article->tags()) ? '.' : ', '; $i++ ?>
  29. <?php } ?>
  30.  
  31. </p>
  32. </div><!-- end .entry -->
  33. <?php endforeach; ?>
  34.  
  35. <?php
  36. if ($pagination->total_rows > $pagination->per_page) echo '<p><br />Pages: '.$pagination->createLinks().'</p>'; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement