74 posts by 20 authors in: Forums > CMS Builder
Last Post: October 8, 2013   (RSS)

Hello Jerry,

Thank you for you post, i already have this code and its very usefull. My latest created website have listing page with more that 800 item, 10 per page. i need something like this new forum script use (First   Prev   4   5   6   7   8   9   10   Next   Last ) so i can see only 7-10 page numbers with first, last, prev and next links.



Here's code that I'm using that's "closer" to the forum code....not exact, but maybe it will help you get waht you need.

            <!-- START PAGINATION CODE -->
            <div class="pagelinks" align="center">
                    if (@!$_GET['page']): $current_page = "1";
                    else: $current_page = $_GET['page'];    
                endif;  ?>
                    $startNumber = max($current_page - 2, 1);
                    $endNumber   = min($current_page + 2, $your_tableMetaData['totalPages']);

                <?php if ($your_tableMetaData['prevPage']): ?>
                    <a href="<?php echo $your_tableMetaData['prevPageLink'] ?>"><img src="/images/arrow-left.png" border="0" /> prev</a>&nbsp;&nbsp;&nbsp;
                    <?php if ($startNumber > '1'): ?>
                        <a href="?<?php echo http_build_query(array_merge($_REQUEST, array( 'page' => '1' ))) ?> ">1</a> ...
                    <?php endif ?>
                <?php else: ?>
                <?php endif ?>    

            <?php foreach (range($startNumber,$endNumber) as $page): ?>
                    <?php if ($page == $current_page): ?>
                     <b>[<?php echo $page; ?>]</b>
                    <?php else: ?>
                     <a href="?<?php echo http_build_query(array_merge($_REQUEST, array( 'page' => $page ))) ?>"><?php echo $page; ?></a>
                    <?php endif ?>
                <?php endforeach; ?>
                <?php if ($your_tableMetaData['nextPage']): ?>
                    <?php if ($your_tableMetaData['totalPages'] > $endNumber): ?>
                        ... <a href="?<?php echo http_build_query(array_merge($_REQUEST, array( 'page' => $your_tableMetaData['totalPages'] ))) ?> "><?php echo $your_tableMetaData['totalPages'];?></a>
                    <?php endif ?>
                        &nbsp;&nbsp;&nbsp;<a href="<?php echo $your_tableMetaData['nextPageLink'] ?>">next <img src="/images/arrow-right.png" border="0" /></a>  
                    <?php else: ?>   
                <?php endif ?>                            
            <!-- /END PAGINATION CODE -->


Hi Kevin,

Thank you for this script! Beautiful solution!


I don't like that when I do a search, it searches all the forums.  I would like it to search the forum I am in or at least allow me to chose which ones to search through.  Specifically in this case, I only want to search the CMSB and add-ons forums, but when I search I got a lot of posts from the old prodocts like article manager.

Also, I don't like see multiple search results from the same thread.  once I click on a result I generally read the whole thread.  But then that same thread shows up several more times in my list of search results.

@everyone: Message received: if we add Unread Topics, it'll have to work cross-device. Thanks for the input!

@ht1080z: The code I used is very similar to weblm's, but $startNumber and $endNumber were generated like this:

// get range of page numbers
$maxLinks = 7;
$selectedPage = $recordsMetaData['page'];
$startNumber = $selectedPage;
$endNumber = $selectedPage;
while ($maxLinks > 1) {
  $match = false;
  if ($endNumber < $recordsMetaData['totalPages'] && --$maxLinks) { $endNumber++; $match = true; }
  if ($startNumber > 1 && --$maxLinks) { $startNumber--; $match = true; }
  if (!$match) { break; }

@wizzle: Excellent point, thanks! I'll add that to my list.

@sidcam: I'll add your #1 to the list too. Thanks for #2, I've fixed that.

All the best,

By Chris - January 31, 2013 - edited: January 31, 2013

Hi Everyone,

We've improved the Forum WYSIWYG's Code button. You can now paste multiple lines of code into a Code block and have your whitespace preserved, and extra (empty) paragraphs are inserted at the top and bottom so that you won't get stuck in a Code block so easily. There were also a few other tweaks for behaviour that was confusing or frustrating.

  I pasted this in!

Right now, there's one known issue with IE with long lines causing the editor to scroll instead of the Code block.

We've also disabled the Spellchecker plugin and enabled browser spellchecking.

Please let us know if you have any feedback!

All the best,

Thank you all for keeping up with this.

I think the spellchecker will be make a big difference. So will the code block fixes.

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php


I had this error by visiting the forum and after having used the back button of the browser :

Couldn't start session! 'session_start(): ps_files_cleanup_dir: opendir(/var/lib/php/session) failed: Permission denied (13)'!


Thanks, Djulia! We'll look into that.

All the best,