"Go to Page #" code

10 posts by 3 authors in: Forums > CMS Builder
Last Post: December 5, 2008   (RSS)

By wevolutions - November 20, 2008

I have about 30 pages on my site and it will soon reach close to 100. I want the visitor to be able to go to a page number instead of just next and previous. Because if they reach a particular page and the browser closes, then they have to start all over again from page 1.

Please let me know the code to insert so that the visitor can input the page number into a search box and then go directly to that page and from there they can go back or forward accordingly.

PS. I migrated my website from Listings Manager to CMSB and I am really enjoying it. Thank you.

Re: [WEVOLUTIONS] "Go to Page #" code

By Dave - November 20, 2008

Hi wevolutions, glad you're enjoying CMS Builder! :)

When you have a viewer list page you specify the page number like this:
viewerList.php?page=2

So you can make a form that links to that directly like this:

<form method="POST" action="">
Go to page:
<input type="text" name="page" value="" size="2" />
<input type="submit" name="go" value="Go" />
</form>

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] "Go to Page #" code

By wevolutions - November 24, 2008

Thanks again Dave. Is there anything that CMSB cannot do?

(ha ha just kidding)

Re: [WEVOLUTIONS] "Go to Page #" code

By studio-a - November 29, 2008

I wanted to ask, having over 100 page numbers may be over whelming as a design point of view (in most cases). Is there a way to refine how many page numbers and which ones will be displayed?

For example:
(This is what the visitor will see as they move through pages 1-15)
<< Previous 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Next >>

(This is what the visitor will see as they move through pages 16-30 and so on)
<< Previous 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Next >>

This was a request during a client meeting and I was not sure how difficult it would be to control the page number display, so I told them I would have to get back with them.

Thanks for you time!

Re: [studio-a] "Go to Page #" code

By Dave - December 1, 2008

Hi studio-a,

Can you post the code that you use to generate your page numbers?

Basically we need to add an if statement that checks if the page number is less than the current page - 7 or the current page + 7 and not show the number if either of those are true.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] "Go to Page #" code

By studio-a - December 1, 2008

Hi Dave,

Attached is a test PHP page we are using to work with the functionality.

Thanks again for your help.

Re: [studio-a] "Go to Page #" code

By Dave - December 3, 2008

Try something like this:

...
<?php foreach (range(1,$dressgallery03MetaData['totalPages']) as $page): ?>

<?php $currentPage = $dressgallery03MetaData['page']; ?>
<?php $maxPageRange = 7; ?>
<?php if ($page < ($currentPage - $maxPageRange)) { continue; } ?>
<?php if ($page > ($currentPage + $maxPageRange)) { continue; } ?>

...


Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] "Go to Page #" code

By studio-a - December 3, 2008 - edited: December 4, 2008

Hi Dave,

Thanks for your reply. The more I read this forum the more I am understand the thought process for such tasks. Your code works for the limiting the amount of page numbers/links to be displayed. However, the numbers do not increase as you click through the previous and next links.

Can you point me in the right direction to increase the corresponding page number/link based on your code? If this is too much no problem.

For example:
(This is what the visitor will see as they move through pages 1-8)
<< Previous 1 2 3 4 5 6 7 8 Next >>

(This is what the visitor will see as they move through pages 9-15 and so on)
<< Previous 9 10 11 12 13 14 15 Next >>

Again, if this is too much to ask no problem. Thanks again for your help!

Re: [studio-a] "Go to Page #" code

By Dave - December 5, 2008

Hi studio-a,

I'd have to take a closer look. Can you email me CMS and FTP login details to dave@interactivetools.com as well as the url to the page with the page links? Email, don't login login details to the forum.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com