View Full Version : Using vB's 'pager' or 'paginator' function
Oreamnos
05-31-2005, 01:22 PM
Does anyone know how to pass a query to vb's pager function (not sure exactly what you call the page 1 2 3 4 Last >> links at the bottom of forumdisplay)? I am integrating some personal pages with vb and would like very much just to use their script/function to break up my long pages over a few pages.
thanks
eric
This is what I am using on my vbGlossary modification (http://www.vbarticles.com/forum/showthread.php?t=61):
$perpage = $vboptions['cinqglossary_perpage'];
$pagenumber = $page;
$glossary_count = $DB_site->query_first("
SELECT COUNT(*) AS count
FROM " . TABLE_PREFIX . "cinqglossary WHERE categoryid=$catid AND valid=1
AND $querycondition
");
$pagecount = ceil($glossary_count['count'] / $perpage);
$pagenumber = iif(!is_numeric($pagenumber) OR $pagenumber < 1 OR $pagenumber > $pagecount, 1, $pagenumber);
$offset = ($pagenumber-1) * $perpage;
$pagenav = construct_page_nav($glossary_count['count'], "glossary.php?do=main&catid=$catid&t=$t", "");
Essentially, $perpage is a variable you set to indicate the number you want to be shown per page, before breaking into another page.
You will next have to find out the total number of results you have ( which is done in the glossary_count query above ).
$pagenav is then inserted into your template.
In your main query to get the results, you will need to add this:
LIMIT $offset,$perpage
at the end of the query.
Hope that helps :)
Oreamnos
05-31-2005, 11:08 PM
Great! Thanks.
I was actually just in the process of explaining the problem I was having when i realized that I had forgotten to create the variable $page from the $_GET['page'] value.
in case anyone needs to know, I just put this at the top of the page and it worked perfectly:globalize($_REQUEST, array('page'=>INT)); but im sure most of you know that already ;)
Thanks so much! :D
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.