how about one entry per page ? can that be done ?

Dr. GBooky is here to help you with your guestbook problems ...
Post Reply
gbookerx
Posts: 3
Joined: Tue Nov 22, 2005 2:45 am

how about one entry per page ? can that be done ?

Post by gbookerx »

how about one entry per page ? can that be done ?

neat script
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

Yes, this can be done.
See the the link to the following thread for the modifications you need to make in the gbook.php file.
viewtopic.php?t=464

You just need to use 1 en 0 instead of 15 and 14 (or 25 and 24)

Greetings,
Henrie
Last edited by Henrie on Tue Nov 22, 2005 11:55 am, edited 1 time in total.
gbookerx
Posts: 3
Joined: Tue Nov 22, 2005 2:45 am

I tried that but could not figure it out

Post by gbookerx »

I tried that but could not figure it out entered 1 instead of 10 but when I got to the - and + could not figure out if it should -0 and +1 I could do it with 2 entries per page
$page=htmlspecialchars("$_REQUEST[page]");
if(empty($page) || preg_match("/\D/",$page)) {$page=1;$start=1;$end=2;}
else {$start=($page*2)-1;$end=$start+1;}

$filesize=filesize($settings['logfile']);
$fp = @fopen($settings['logfile'],"rb") or problem("Can't open the log file ($settings[logfile]) for reading! CHMOD this file to 666 (rw-rw-rw)!");
$content=@fread($fp,$filesize);
fclose($fp);
$content = trim(chop($content));
$lines = explode($settings['newline'],$content);

if ($filesize == 0) {$total=0;}
else {
$total = count($lines);
if ($end > $total) {$end=$total;}
$pages = ceil($total/2);
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

The code for one entry per page would be

Code: Select all

$page=gbook_isNumber($_REQUEST['page']);
if ($page>0) {
	$start=($page*1)-0;$end=$start+0;
} else {
	$page=1;$start=1;$end=1;
}

$filesize=filesize($settings['logfile']);
$fp = @fopen($settings['logfile'],"rb") or problem("Can't open the log file ($settings[logfile]) for reading! CHMOD this file to 666 (rw-rw-rw)!");
$content=@fread($fp,$filesize);
fclose($fp);
$content = trim(chop($content));
$lines = explode($settings['newline'],$content);

if ($filesize == 0) {$total=0;}
else {
$total = count($lines);
	if ($end > $total) {$end=$total;}
$pages = ceil($total/1);
echo '<p>Displaying page '.$page.' of '.$pages.'. Pages: ';
	for ($i=1; $i<=$pages; $i++) {
		if($i == $page) {echo "<b>$i</b>\n";}
        else {echo '<a href="gbook.php?page='.$i.'">'.$i.'</a> ';}
	}
}
Greetings,
Henrie
FruitBeard
Posts: 38
Joined: Thu Jul 21, 2005 6:25 pm

page ammount display using seetings.php

Post by FruitBeard »

Hi, to make it so you can easily change the ammount of comments displayed per page.

In settings .php add this,

/*This determines the ammount of submitted comments per page- DISPLAY_AMMOUNT_MATH, should always be 1 less than DISPLAY_AMMOUNT*/
$settings['DISPLAY_AMMOUNT'] = 10;
$settings['DISPLAY_AMMOUNT_MATH'] = 9;

or whichever two numbers you choose or want.

and then find this portion of code in gbook.php

$page=gbook_isNumber($_REQUEST['page']);
if ($page>0) {
$start=($page*10)-9;$end=$start+9;
} else {
$page=1;$start=1;$end=10;
}

and this portion of code:

$pages = ceil($total/10);

ok, replace all number 10's with $settings['DISPLAY_AMMOUNT']
and replace all number 9's with $settings['DISPLAY_AMMOUNT_MATH']
FruitFully yours

http://www.fgps.com/keith/
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

In my guestbook i have made a similar change only i have changed all number 10's with $settings['DISPLAY_AMMOUNT']
and i changed all number 9's with ($settings['DISPLAY_AMMOUNT']-1)

This way you only need to add one new variable to settings.php:
/*This determines the ammount of submitted comments per page*/
$settings['DISPLAY_AMMOUNT'] = 10;

Greetings Henrie
Guest

Post by Guest »

FruitBeard

Ah ha, well done Henrie, I never thought of that at the time, it makes total sense now i see it and I shall change mine to similar right now,

Cheers

Fruity
Post Reply