dajare

Paginate homepage

Mar 24th, 2010
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1.  HOMEPAGE code to paginate ARTICLES in Wolf CMS...
  2.  
  3. <?php // set limit value in next line to match per-page value below ?>
  4. <?php $last_articles = $this->find('/articles')->children(array('limit'=>3, 'offset'=>($pagination->cur_page)*($pagination->per_page), 'order'=>'page.created_on DESC')); ?>
  5.  
  6. <?php foreach ($last_articles as $article): ?>
  7.  
  8. <div class="entry">
  9.   <h3><?php echo $article->link($article->title); ?></h3>
  10.   <?php // Whatever else you want to include: teaser? meta? etc. ?>
  11. </div><!-- end .entry -->
  12.  
  13. <?php endforeach; ?>
  14.  
  15. <?php use_helper('Pagination');
  16. $pagination = new Pagination(array(
  17.  'base_url' => '/?page=', // if Wolf is in SUBDIR, but subdir between / and ? - e.g. '/wolf?page='
  18.  'total_rows' => $this->find('/articles')->childrenCount(),
  19.  'per_page' => 3,
  20.  'num_links' => 8,
  21.  'cur_page' => (isset($_GET['page']) ? $_GET['page']: 1)
  22. )); ?>
  23.  
  24. <?php if ($pagination->total_rows > $pagination->per_page) echo '<p><br />Pages: '.$pagination->createLinks().'</p>'; ?>
Add Comment
Please, Sign In to add comment