View Full Version : how do I use the function construct_page_nav()??
DrewM
04-14-2006, 11:24 PM
Well I'm tring to do paging and was wondering how to use the function construct_page_nav() to do this I saw this in a tutorial. Please help!
RS_Jelle
04-15-2006, 01:08 PM
It's explained in this tutorial (https://vborg.vbsupport.ru/showthread.php?t=98009) ;)
DrewM
04-15-2006, 02:23 PM
this is not in that tutorial.
DrewM
04-16-2006, 05:19 PM
bump also I know this is in A tutorial but I was hoping for then in the tutorial
Adrian Schneider
04-16-2006, 05:28 PM
I use a block of code like this wherever I need it:
// Construct Page Navigation
$total = $dmEntry->viewTotalEntries($userid, $whereClause, $canViewPrivate);
$url = "viewblog.php?{$sID}userid=$userid";
$offset = ($vbulletin->GPC['page'] - 1) * $vbulletin->GPC['pp'];
$limit = "$offset, " . $vbulletin->GPC['pp'];
$pageNavigation = construct_page_nav($vbulletin->GPC['page'],
$vbulletin->GPC['pp'], $total, $url, '&pp=' . $vbulletin->GPC['pp']
);
You should only have to edit $total and $url for this to work. Make sure you have $vbulletin->input->clean_array_gpc('g', array(
'pp' => TYPE_UINT,
'page' => TYPE_UINT
));in your code as well, and they SHOULD have default values... I use this function I wrote becuase I am lazy:
defaultGPC( array(
'pp' => $vbulletin->options['blog_max_entry_display'],
'page' => 1
));
the function
function defaultGPC($data)
{
global $vbulletin;
foreach ($data as $key => $value)
{
if (!$vbulletin->GPC[$key])
{
$vbulletin->GPC[$key] = $value;
}
}
}
If you aren't lazy, then just something like this:
Then placing something like:
if (!$vbulletin->GPC['page'])
{
$vbulletin->GPC['page'] = 1;
}
if (!$vbulletin->GPC['pp'])
{
$vbulletin->GPC['pp'] = 15;
} does the exact same thing.
<if condition="$pageNavigation"><div align="right" style="margin-bottom: 5px">$pageNavigation</div></if>
<!-- main table -->
<if condition="$pageNavigation"><div align="right" style="margin-top: 5px">$pageNavigation</div></if>
To display it.
akanevsky
04-16-2006, 07:34 PM
I suggest you look in functions.php for the definition of the function.
DrewM
04-16-2006, 08:31 PM
thanks to both of you.
Well I have been tring to get this to work but it doesn't! I tryed to change so instaed of &page=1 i'm trting to get &pagenum=2 because with &page=1 will mess up my site and it shows al the resaults on on page this is my code:
if ($_REQUEST['page'] == 'news')
{
$news1 = $db->query_read("SELECT * FROM " . TABLE_PREFIX . "site_news ORDER BY newsid DESC");
while ($news = $db->fetch_array($news1)) {
eval('$rowbits .= "' . fetch_template('site_v3_news_single') . '";');
}
function defaultGPC($data)
{
global $vbulletin;
foreach ($data as $key => $value)
{
if (!$vbulletin->GPC[$key])
{
$vbulletin->GPC[$key] = $value;
}
}
}
$vbulletin->input->clean_array_gpc('g', array(
'pp' => TYPE_UINT,
'pagenum' => TYPE_UINT
));
defaultGPC( array(
'pp' => 1,
'pagenum' => 1
));
// Construct Page Navigation
$total = $db->num_rows($news1);
$url = "index.php?page=news{$sID}";
$offset = ($vbulletin->GPC['pagenum'] - 1) * $vbulletin->GPC['pp'];
$limit = "$offset, " . $vbulletin->GPC['pp'];
$pageNavigation = construct_page_nav($vbulletin->GPC['pagenum'],
$vbulletin->GPC['pp'], $total, $url, '&pp=' . $vbulletin->GPC['pp']
);
//templeates are here i took them out to show
}
PLEASe help!
DrewM
04-17-2006, 08:32 PM
bump
DrewM
04-19-2006, 10:33 AM
bump
DrewM
04-20-2006, 11:16 AM
;bump;
DrewM
04-22-2006, 03:08 PM
bump
DrewM
04-23-2006, 04:59 PM
bump
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.