Previous / Next arrows for skipping through pages

General discussions about WebYep
Post Reply
testing1
Rank 1
Rank 1
Posts: 23
Joined: Tue Oct 13, 2009 5:25 pm

Previous / Next arrows for skipping through pages

Post by testing1 » Thu Aug 19, 2010 4:23 pm

Hi Johannes and other Wizards of the Web,

Is there a way to use Previous / Next arrows to skip through (WEBYEP_DI=X) pages? For example, one of my templates will be called "members.php", I will add to this list regularly. The visitor will click the Previous / Next arrows and skip through WEBYEP_DI=0001 - WEBYEP_DI=1000. I'm guessing I'll just have 100 pages created, maximum, but I need the freedom of a long range.

the arrows could be an image or this

Code: Select all

&larr Previous | Next &rarr

I'm interested in applying a piece of code that only skips through a designated number of WEBYEP_DI=X…

Any help is appreciated?

johannes
Objective Development
Objective Development
Posts: 815
Joined: Fri Nov 10, 2006 4:39 pm
Contact:

Re: Previous / Next arrows for skipping through pages

Post by johannes » Thu Aug 26, 2010 5:31 pm

First, please note that the URL query argument changed from WEBYEP_DI to DOC_INST in WebYep 1.4.6.

The code you are asking for could look something like this:

Code: Select all

<div><?php
   $iMaxDocID = 100;
   $sSelf = $_SERVER['PHP_SELF'];
   $iDocID = isset($_GET['DOC_INST']) ? (int)$_GET['DOC_INST']:0;
   $sPrevText = "&larr; Previous";
   $sNextText = "Next &rarr;";
   if ($iDocID > 1) printf("<a href=\"%s?DOC_INST=%d\">%s</a>", $sSelf, $iDocID - 1, $sPrevText);
   else echo $sPrevText;
   echo " | ";
   if ($iDocID < $iMaxDocID) printf("<a href=\"%s?DOC_INST=%d\">%s</a>", $sSelf, $iDocID + 1, $sNextText);
   else echo $sNextText;
?></div>


The main problem with this code is, that it cannot determine how many pages are actually filled with content!
So it will offer the "next" link even if the next page actually has no content...:(

testing1
Rank 1
Rank 1
Posts: 23
Joined: Tue Oct 13, 2009 5:25 pm

Re: Previous / Next arrows for skipping through pages

Post by testing1 » Mon Jan 17, 2011 3:32 am

Hi Johannes,

The code works great. Currently, when I hide a page within the loop element, it still shows up when the user click previous/next.

Example: using the previous/next arrow, the user goes from DOC_INST=1 to DOC_INST=10 with every page page in between showing up. Is there a way the code can "skip" any pages that are hidden?

Thanks!
8)

marcus
Objective Development
Objective Development
Posts: 170
Joined: Tue Nov 30, 2010 1:25 pm

Re: Previous / Next arrows for skipping through pages

Post by marcus » Mon Jan 17, 2011 1:11 pm

testing1 wrote:Is there a way the code can "skip" any pages that are hidden?

I'm afraid, this isn't possible at the moment.

Post Reply