Next and Prev page

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 11, 2013   (RSS)

By gregThomas - March 11, 2013

Hi Craig,

You'll have to write something custom to get this working, this is how I would do it:

<?php 
 // load records from 'blog'
  list($blogRecords, $blogMeta) = getRecords(array(
    'tableName'   => 'blog',
    'perPage'     => '10',
    'loadUploads' => true,
    'allowSearch' => false,
  ));

?>


          <div class="row-fluid">
          <div class="pagination pagination-small pagination-centered offset1 span10">
            <ul>
              <li class="disabled">
                <a href="<?php echo $blogMeta['prevPageLink']; ?>">
                  <i class="icon-angle-left"></i>
                </a>
              </li>
              <?php foreach( range('1',$blogMeta['totalPages']) as $pageNumber): ?>
                <li <?php if($pageNumber == $blogMeta['page']): ?>class="active"<?php endif; ?>>
                  <a href="/pageLink.php?page=<?php echo $pageNumber; ?>"><?php echo $pageNumber; ?></a>
                </li>
              <?php endforeach; ?>
              <li>
                <a href="<?php echo $blogMeta['nextPageLink']; ?>">
                  <i class="icon-angle-right"></i>
                </a>
              </li>
            </ul>
          </div>
        </div>

This is just example code, so you might have to change the name of some of the variables used. (You'll probably have to replace $blogMeta with $blogMetaData, and replace pageLink.php with the page name).

The range function generates an array of numbers the same size as the number of pages, then the foreach loops through the array generating the number list elements. 

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By KCMedia - March 11, 2013

Hi Greg

thanks mate was a good start i got it all working now cheers.

Thanks



Craig

KC Media Solutions

www.kcmedia.biz