PDA

View Full Version : i should know this but don't


sabret00the
05-26-2004, 03:30 PM
how do i select the number of posts on a page in a thread? (rather than all posts in the thread?

Tony G
05-27-2004, 06:42 AM
Is there even a variable that defines that number?

sabret00the
05-27-2004, 11:24 AM
i hope so as the $bbuerinfo[maxpost] variable seems to be set at -1 for most of my users, although i suppose that i could user

if ($bbuserinfo[maxpost] < 15)
{
$bbuserinfo[maxpost] = $vboptions[maxpost];
}

if ($thread[replycount] > $bbuserinfo[maxpost])
{
$postsonthispage = $thread[replycount] - $perpage / $pages;
}
else
{
$postsonthispage = $thread[replycount];
}


i think that should give you the data :o feel free to correct me.

Xenon
05-27-2004, 12:11 PM
hmm, doesn'T $perpage already give you the ammount of posts per page?

sabret00the
05-27-2004, 12:15 PM
thinking about it $perpage should be the same as $bbuserinfo[maxposts]

Xenon
05-27-2004, 12:44 PM
it's a bit more complicated ^^

example from showthread.php:
// set $perpage

if (!$perpage)
{
$perpage = $bbuserinfo['maxposts'];
}

$checkmax = explode(',', $vboptions['usermaxposts'] . ',' . $vboptions['maxposts']);
if ($perpage < 1 OR $perpage > max($checkmax))
{
$perpage = $vboptions['maxposts'];
}

so $perpage can be defined in several ways, as parameter of the url, as a user setting, as $vboptions[mx] aso.

sabret00the
05-27-2004, 01:12 PM
so you trying to tell me that my code is wrong and $postsonthispage wouldn't return anything?

Xenon
05-27-2004, 06:14 PM
well, it would return something, but not what you want to get.

sabret00the
05-27-2004, 06:49 PM
lol :( any help on how to aquire the data i'm trying to get?

i thought maybe the errors in this line?
$postsonthispage = $thread[replycount] - $perpage / $pages;

as it should be something like
$postsonthispage = $thread[replycount] - ($perpage / $pages);
get the sum of $perpage dived $pages then subtract that total from the $thread[replycount] and you should have your total?

Xenon
05-27-2004, 07:11 PM
hmm, try to use $counter, iirc it already stores the ammount of actual shown posts.

sabret00the
05-27-2004, 11:11 PM
omg, it works :D

thanks xenon :D :D :D

sabret00the
05-27-2004, 11:15 PM
plus it seems that templates can't do maths :(

Xenon
05-28-2004, 10:42 AM
you're welcome :)

hmm, they should do normally, maybe just not correctly ^^