Page 1 of 1
how about one entry per page ? can that be done ?
Posted: Tue Nov 22, 2005 3:47 am
by gbookerx
how about one entry per page ? can that be done ?
neat script
Posted: Tue Nov 22, 2005 6:45 am
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
I tried that but could not figure it out
Posted: Tue Nov 22, 2005 7:25 am
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);
Posted: Tue Nov 22, 2005 12:11 pm
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
page ammount display using seetings.php
Posted: Tue Nov 22, 2005 8:55 pm
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']
Posted: Tue Nov 22, 2005 10:15 pm
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
Posted: Tue Nov 22, 2005 10:50 pm
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