Page 1 of 1

I want Less than 10 Messages on One Page - GBOOK

Posted: Wed Nov 07, 2007 4:03 pm
by happylinks
Script: GBOOK
Version of script: Latest

I have a small website and i want to add the guestbook in there, but it's to big for my site, can i modify the script somewhere that i only have 5 messages on one page?

Greetz Michiel

Posted: Wed Nov 07, 2007 5:11 pm
by Henrie
See these topics:
viewtopic.php?t=464
viewtopic.php?t=527

The mentioned line numbers will be different in the latest version of the guestbook script.

Greetings,
Henrie

It works almost

Posted: Wed Nov 07, 2007 6:10 pm
by happylinks
Yes it works, but only when i open the page, when i click on Next it goes back to 10.

This is my site:
www.happylinks.nl/gastenboek.html

My script is:

Code: Select all

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

$lines=file($settings['logfile']);
$total = count($lines);

if ($total > 0) {
    if ($end > $total) {$end=$total;}
    $pages = ceil($total/5);

    $prev_page = ($page-1 <= 0) ? 0 : $page-1;
    $next_page = ($page+1 > $pages) ? 0 : $page+1;

    echo '<p>Er zijn '.$total.' berichten op '.$pages.' pagina&acute;s.<br />';

    $gbook_nav = '';

    if ($prev_page) {
        $gbook_nav .= '
        <a href="gbook.php?page=1"><< Eerste</a>
        &nbsp;|&nbsp;
        <a href="gbook.php?page='.$prev_page.'">< Terug</a>
        &nbsp;|&nbsp;
        ';
    }

    for ($i=1; $i<=$pages; $i++) {
        if ($i <= ($page+5) && $i >= ($page-5)) {
           if($i == $page) {$gbook_nav .= ' <b>'.$i.'</b> ';}
           else {$gbook_nav .= ' <a href="gbook.php?page='.$i.'">'.$i.'</a> ';}
        }
    }

    if ($next_page) {
        $gbook_nav .= '
        &nbsp;|&nbsp;
        <a href="gbook.php?page='.$next_page.'">Volgende ></a>
        &nbsp;|&nbsp;
        <a href="gbook.php?page='.$pages.'">Laatste >></a>
        ';
    }

    echo $gbook_nav;
}

echo '</p>

Posted: Wed Nov 07, 2007 7:11 pm
by Henrie
It should be like this

Code: Select all

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

$lines=file($settings['logfile']);
$total = count($lines);

if ($total > 0) {
	if ($end > $total) {$end=$total;}
    $pages = ceil($total/5);

    $prev_page = ($page-1 <= 0) ? 0 : $page-1;
    $next_page = ($page+1 > $pages) ? 0 : $page+1;
You can see yourself what the difference is.

Greetings,
Henrie

Thanks

Posted: Wed Nov 07, 2007 9:30 pm
by happylinks
Thanks for your quick reaction, it worked and you helped me a lot!

Michiel Westerbeek