PDA

View Full Version : [HOW TO - vB4] Paginating Results


cellarius
24 Aug 2009, 19:42
Introduction

Not very much has changed regarding how pagination works since vB 3.8, but quite enough to warrant an update of Revan's (http://www.vbulletin.org/forum/member.php?u=47482) great tutorial (http://www.vbulletin.org/forum/showthread.php?t=120540), dating from 2006. Kudos to Revan.

As Revan I assume you know your way around php and can understand at least roughfly what each bit of the code does. There'll be explanations, of course, but this is for coders and mod developers.

The main work for pagination has to be done in the PHP-code, still no surprise there.

Cleaning URL parameters

We start off by cleaning the URL parameters that will tell our paginator how many entries to show per page and on which page of the resultset we're actually on

$vbulletin->input->clean_array_gpc('r', array(
'perpage' => TYPE_UINT,
'pagenumber' => TYPE_UINT,
)); .
Counting results

The next step is to count the number of resuts that our actual database query will return (this query we will meet later on - it's an example that will throw all users with no posts).

$cel_users = $db->query_first("
SELECT COUNT('userid') AS users_count
FROM " . TABLE_PREFIX . "user AS user
WHERE user.posts = '0'
");.
Settings & sanitizing

Next we're off to do some settings: The first argument is our counting result. The last two arguments are the maximum number of results per page (100) and the default number of results per page (20). Note how the first argument is the result of the count query above. You can replace those with settings from the AdminCP by inserting the corresponding variables obviously.

sanitize_pageresults($cel_users['users_count'], $pagenumber, $perpage, 100, 20);.
Orientation - where are we?

Now some stuff to determine on which page we're on and which results to show. Note how you have to provide the results of our initial count query:

if ($vbulletin->GPC['pagenumber'] < 1)
{
$vbulletin->GPC['pagenumber'] = 1;
}
else if ($vbulletin->GPC['pagenumber'] > ceil(($cel_users['users_count'] + 1) / $perpage))
{
$vbulletin->GPC['pagenumber'] = ceil(($cel_users['users_count'] + 1) / $perpage);
}
$limitlower = ($vbulletin->GPC['pagenumber'] - 1) * $perpage;
$limitupper = ($vbulletin->GPC['pagenumber']) * $perpage;.
The main query

Now the query that throws all users with no posts - just an example, obviously. Note the LIMIT - this has to be added to the original query to delimit the resultset for the actual page

$result = $db->query_read("
SELECT user.username, user.userid
FROM " . TABLE_PREFIX . "user as user
WHERE user.posts = '0'
ORDER BY username DESC
LIMIT $limitlower, $perpage
");.
Constructing pagenav

The last (but one) thing to do in the PHP code is to finally call the function to construct the actual page-nav and saving it's output to a variable for passing to the template.
Some explanation for the arguments that must/can be passed to this function are in the code.
Of course, the name of the file (yourfile.php) needs to be adapted to the file name your using the pagination on.
Only the first four arguments are mandatory. You can leave the rest away if not needed, I added them for documentation.
The ? that starts the parameters after myfile.php needs to be there, since atm the page parameter always is prefixed with an &. If there are no other parameters present as is the case in this example, the links will look like "yourfile.php?&page=2". This is, of course, wrong, but works; without the ? the link would be "yourfile.php&page=2", which is even more wrong, since it does not work. In vB 3 pagination handled this correctly. I filed this as a bug in vB4 beta 3. Maybe I'm missing something, or this will be resolved - I'll keep you posted.$pagenav = construct_page_nav(
$vbulletin->GPC['pagenumber'],
$perpage,
$cel_users['users_count'],
'yourfile.php?' . $vbulletin->session->vars['sessionurl'], // the pagenav-link
'', // to pass a second portion or the pagenav-link, gets directly appended to above
'', // to pass an anchor
'', // SEO-Link for thread, forum, member... pages - make the pagenav-links seo'ed if you use the paginator on one of those
'', // Array to pass linkinfo for SEO-Link-Method
'' // Array to pass additional Info for SEO-Link-Method
);
.
Registering pagenav for templates

As with all variables in vB4, the newly created $pagenav has to be registered to be used inside the template:

$templater = vB_Template::create('cel_test_pagination');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
// Need to add for pagenav
$templater->register('pagenav', $pagenav);
$templater->register('pagenumber', $pagenumber);
$templater->register('perpage', $perpage);
$templater->register('output', $output);
print_output($templater->render());.
Template code

Now you just have to put the pagenav-code into your template, and we're done. Note that the id of the surrounding div should be changed to "pagination_bottom" or "pagination_top" accordingly.

<vb:if condition="$pagenav">
<div id="pagination_top">
{vb:raw pagenav}
</div>
</vb:if>Have fun!


-c
As of now (beta 3), there are still some issues that need to be resolved regarding pagination. They are minor and there should not be substantial changes, but be aware of that. For example, the setting of results shown per page does not work yet - 20 is hardcoded into the sanitizing function.

BBR-APBT
28 Dec 2009, 08:54
How to get this to work with $_POST.

Every time I click a link in the pagination it resets the post variables.

When I use $_GET it shows either the security token or the session hash.

Thanks for any help.

cellarius
28 Dec 2009, 10:41
The pagination system, as far as I know, is designed to work with URL parameters only. If you want to preserve data entered via a form in post mode, you need to pass the data entered to the pagination class by adding parameters to the pagenav link, then you need to query it accordingly when the page gets reloaded upon page change. Anyway, wihtout seeing your code it's hard to say where you are going wrong.

BBR-APBT
28 Dec 2009, 15:23
here ya go http://pastebin.com/m5dd777d5

If I use $_get how do I remove the sessionhash or the securitytoken out of the url?

It loads the first page but each page after that has no variables.

cellarius
28 Dec 2009, 18:47
First, whenever you use get or post variables, you should always use the vbulletin input cleaner to make them safe. If you don't know how, there's an article somewhere here.

Second, why would you want to get rid of the sessionhash? It's only showing if you have cookies disabled, and if you remove it, it will break login for people w/o cookies.

Third, as I said, when you change pages, you basically reload them. Post variables won't survive that. You need to save the get parameters into variables, pass those variables as parameters to the pagination URL, and then read them from the URL parameters upon reload.

Basically (forgoing input cleaner here, for simplicity:


// use if isset constructions below to decide
// whether $_POST or $_GET should take precedence

$var1 = $_POST['var1']; // coming from your post form - would be easier to use get-method there, too
$var2 = $_GET['var1']; // coming from the URL parameter


// your code


// then, when initiating pagination add your variable as parameter

$pagenav = construct_page_nav(
$vbulletin->GPC['pagenumber'], $perpage,
$cel_ped['ped_count'], $vbulletin->options['bbr_peds_url'] . '/results.php?' . $vbulletin->session->vars['sessionurl'] . 'var1=' . $var1,

BBR-APBT
28 Dec 2009, 19:18
I don't want to get rid of the session hash or security token I just want to hide it from the URL with $_GET for the simple fact is I don't want my users passing their sessionhash or security token around to each other.

On this search page only would it be safe to turn off CSRF_PROTECTION as long as I clean what can be inputed?

cellarius
28 Dec 2009, 19:35
Visibility of the security token is not a problem securitywise. It is visible in the source code anyway. The sessionhash is passed along via URL by vB if cookies are disabled, that's the way it is. And no, disabling CSRF protection is not a good idea, it's there for a reason.

BBR-APBT
28 Dec 2009, 19:38
Thanks so much for all your help man.

Last question do I need to add the following to $_GET forms?

<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="s" value="$session[sessionhash]" />

cellarius
28 Dec 2009, 19:45
If you're using GET, you don't need the security token, but you do need the session (as I said, leaving that out will break log in for everyone with cookies disabled).

On CSRF protection, you may want to read http://www.vbulletin.org/forum/showthread.php?t=177013

BBR-APBT
28 Dec 2009, 23:07
Again Thanks for all the help Great Article.

Most of my problem boiled down to the sql statment.

I had

SELECT DISTINCT COUNT(blah


When I should have had.

SELECT COUNT(DISTINCT blah


So even with _GET it wasn't working correctly.

I used this same tutorial on several other pages of mine and it went flawlessly.

Thanks again for the fast answers and the great help.


P.S. I secure my code after its working just to narrow down problems.

S1OPP
05 Jan 2010, 00:48
I would really appreciate it if somebody could help me out.

I've built a page that pulls row from a sql db. Now I need to paginate the page as there are too many rows for one page.

I've followed the instructions as far as I can, changing only a few things, such as the sql queries.

The php is now limiting the number of rows to the correct perpage number. I've added the pagenav code to my custom template, but no matter what I do, the pagenav doesn't show.


Any help would be greatly appreciated.
S1OPP

BBR-APBT
05 Jan 2010, 06:07
I would really appreciate it if somebody could help me out.

I've built a page that pulls row from a sql db. Now I need to paginate the page as there are too many rows for one page.

I've followed the instructions as far as I can, changing only a few things, such as the sql queries.

The php is now limiting the number of rows to the correct perpage number. I've added the pagenav code to my custom template, but no matter what I do, the pagenav doesn't show.


Any help would be greatly appreciated.
S1OPP
First off it would be good to post code when asking for help. If we can't see it and all your saying is it don't work, it makes it very hard to help you. There could be a million reasons why it isn't working for you. I used this tutorial several times and it works every time like a charm.

cellarius
05 Jan 2010, 06:25
^^What he said :)

I used this tutorial several times and it works every time like a charm.
Good to know ;)

S1OPP
05 Jan 2010, 07:24
no problem.

sightings.php
<?php

// ####################### SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);

// #################### DEFINE IMPORTANT CONSTANTS #######################

define('THIS_SCRIPT', 'sightings');
define('CSRF_PROTECTION', true);
// change this depending on your filename

// ################### PRE-CACHE TEMPLATES AND DATA ######################
// get special phrase groups
$phrasegroups = array();

// get special data templates from the datastore
$specialtemplates = array();

// pre-cache templates used by all actions
$globaltemplates = array('custom_sightings',
);

// pre-cache templates used by specific actions
$actiontemplates = array();

// ######################### REQUIRE BACK-END ############################
// if your page is outside of your normal vb forums directory, you should change directories by uncommenting the next line
// chdir ('/path/to/your/forums');
require_once('./global.php');

// #######################################################################
// ######################## START MAIN SCRIPT ############################
// #######################################################################

$navbits = construct_navbits(array('' => 'Sightings'));
$navbar = render_navbar_template($navbits);

// ###### YOUR CUSTOM CODE GOES HERE #####
$pagetitle = 'Sightings';

$link = mysql_connect("xxxxxxxxxxxxx", "xxxxxxx", "xxxxxxx") or die("Impossible to connect :" . mysql_error());



$row_usersightings = array ();

$vbulletin->input->clean_array_gpc('r', array(
'perpage' => TYPE_UINT,
'pagenumber' => TYPE_UINT,
));


mysql_select_db("mothstats") or die(mysql_error());


$cel_users = mysql_query("
SELECT COUNT('id') AS row_count
FROM sightings
");

sanitize_pageresults($cel_users['row_count'], $pagenumber, $perpage, 100, 20);

if ($vbulletin->GPC['pagenumber'] < 1)
{
$vbulletin->GPC['pagenumber'] = 1;
}
else if ($vbulletin->GPC['pagenumber'] > ceil(($cel_users['row_count'] + 1) / $perpage))
{
$vbulletin->GPC['pagenumber'] = ceil(($cel_users['row_count'] + 1) / $perpage);
}
$limitlower = ($vbulletin->GPC['pagenumber'] - 1) * $perpage;
$limitupper = ($vbulletin->GPC['pagenumber']) * $perpage;


$usersightings = mysql_query("SELECT * FROM sightings
ORDER BY id DESC
LIMIT $limitlower, $perpage");

while ($row = mysql_fetch_assoc($usersightings))
{
$row_usersightings[] = $row;
}

$pagenav = construct_page_nav(
$vbulletin->GPC['pagenumber'],
$perpage,
$cel_users['row_count'],
'sightings.php?' . $vbulletin->session->vars['sessionurl'] // the pagenav-link
);


// ###### NOW YOUR TEMPLATE IS BEING RENDERED ######
vB_Template::preRegister('custom_sightings',array('row_usersightings' => $row_usersightings));
$templater = vB_Template::create('custom_sightings');
$templater->register_page_templates();
$templater->register('navbar', $navbar);
$templater->register('pagetitle', $pagetitle);
$templater->register('row_usersightings', $row_usersightings);
$templater->register('pagenav', $pagenav);
$templater->register('pagenumber', $pagenumber);
$templater->register('perpage', $perpage);
$templater->register('output', $output);
print_output($templater->render());


?>

Templats : custom_sightings
{vb:stylevar htmldoctype}
<html xmlns="http://www.w3.org/1999/xhtml" dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<head>
<title>{vb:raw vboptions.bbtitle}</title>
{vb:raw headinclude}
</head>
<body>

{vb:raw header}

{vb:raw navbar}

<vb:if condition="$pagenav">
<div id="pagination_top">
{vb:raw pagenav}
</div>
</vb:if>

<div id="pagetitle">
<h1>{vb:raw pagetitle}</h1>
</div>

<h2 class="blockhead">Title</h2>
<div class="blockbody">
<div class="blockrow">
<div id="container">
<div style="padding-left: 10px; padding-top:5px;">
<a href="sightingssubmit.php"><strong>Submit a sighting </strong></a> | <a href="sightings.php"><strong>Show all sightings </strong></a>
</div>
<br />
<table width="95%" border="0" align="center" bgcolor="#FCFCFC">
<tr>
<td bgcolor="#848E7B"><div align="left" class="style1">No.</div></td>
<td bgcolor="#848E7B"><div align="left" class="style1">Species</div></td>
<td bgcolor="#848E7B"><div align="left" class="style1">Date</div></td>
<td bgcolor="#848E7B"><div align="left" class="style1">Location</div></td>
<td bgcolor="#848E7B"><div align="left" class="style1">Recorder</div></td>
<td bgcolor="#848E7B"><div align="left" class="style1">Details</div></td>
</tr>

<vb:each from="row_usersightings" key="rowid" value="rowinfo">
<tr>
<td width="30" valign="top" bgcolor="#FFFff4"><div align="left" class="style131 "> {vb:var rowinfo.id} </div></td>
<td width="150" valign="top" bgcolor="#FFFff4"><div align="left" class="style131"> {vb:var rowinfo.species}</div></td>
<td width="50" valign="top" bgcolor="#FFFff4"><div align="left" class="style131"> {vb:var rowinfo.date}</div></td>
<td width="120" valign="top" bgcolor="#FFFff4"><div align="left" class="style131"> {vb:var rowinfo.location}</div></td>
<td width="100" valign="top" bgcolor="#FFFff4"><div align="left" class="style131"> {vb:var rowinfo.recorder}</div></td>
<td width="350" valign="top" bgcolor="#FFFff4"><div align="left" class="style131"> {vb:var rowinfo.details}</div></td>
</tr>
</vb:each>

</table>

</div>

</div>
</div>
{vb:raw footer}
</body>
</html>

S1OPP
06 Jan 2010, 21:07
Worked it out now,

thanks.

cellarius
07 Jan 2010, 04:15
Sorry, didn't come around to look at your code - but you working it out yourself is much better anyway :)

MrNase
22 Jan 2010, 07:19
Dont forget to use the &amp; like this when passing additional attributes. :)


'do=category&amp;id='.$vbulletin->GPC['id']



This one seems to work at first but it does not when using the page number input:

'do=category&id='.$vbulletin->GPC['id']

Jaxel
11 Apr 2010, 02:15
As of VB 4.0.3, I now have errors with page pagination on custom mods...

Example: http://test.8wayrun.com/media/c9-kogarasumaru

With VB 4.0.2, it looked fine, but now the last 3 elements are shifted.

Jaxel
21 Apr 2010, 16:33
Only happens in Chrome... only with vb4.0.3

http://www.vbulletin.org/forum/attachment.php?attachmentid=116129

This is code...
<vb:if condition="$pagenav">
<div id="pagination_top" style="float: right;">
{vb:raw pagenav}
</div><br /><br />
</vb:if>

EquinoxWorld
22 Jul 2011, 02:11
Just wanted to say thank you for this article on pagination, I was finally able to understand it thanks to your post. Here is my example for those who are still trying to understand maybe this helps.

<?php
require_once('./global.php');

$vbulletin->input->clean_array_gpc('r', array(
'perpage' => TYPE_UINT,
'pagenumber' => TYPE_UINT,
));

$cel_users = $db->query_first("
SELECT COUNT('edition') AS users_count
FROM oftw_hall_of_fame
");

sanitize_pageresults($cel_users['users_count'], $pagenumber, $perpage, 50, 5);

if ($vbulletin->GPC['pagenumber'] < 1)
{
$vbulletin->GPC['pagenumber'] = 1;
}
else if ($vbulletin->GPC['pagenumber'] > ceil(($cel_users['users_count'] + 1) / $perpage))
{
$vbulletin->GPC['pagenumber'] = ceil(($cel_users['users_count'] + 1) / $perpage);
}
$limitlower = ($vbulletin->GPC['pagenumber'] - 1) * $perpage;
$limitupper = ($vbulletin->GPC['pagenumber']) * $perpage;

$pagenav = construct_page_nav(
$vbulletin->GPC['pagenumber'],
$perpage,
$cel_users['users_count'],
'oftw_hall_of_fame.php?' . $vbulletin->session->vars['sessionurl'], // the pagenav-link
'', // to pass a second portion or the pagenav-link, gets directly appended to above
'', // to pass an anchor
'', // SEO-Link for thread, forum, member... pages - make the pagenav-links seo'ed if you use the paginator on one of those
'', // Array to pass linkinfo for SEO-Link-Method
'' // Array to pass additional Info for SEO-Link-Method
);

$result = $db->query_read("SELECT * FROM oftw_hall_of_fame LIMIT $limitlower, $perpage");

if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo "<center><table>";
while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td><center><u style=color:#417394;font-size:20px;><b style=color:#417394;>Signature Of The Week Edition #&nbsp;".$row[7]."&nbsp;</b></u></center>";
echo "<center>Won With&nbsp;".$row[2]."&nbsp;Votes</center>";
echo "<center>Nominated&nbsp;By:&nbsp;<b style=color:#3B81B7;><a href=http://development.aniworlds.net/member.php?".$row[6]."-".$row[4].">".$row[4]."&nbsp;</a></b></center>";
echo "<center>Added:&nbsp;".date("F j, Y g:i a", strtotime($row[3]))."</center>";
echo "<center>Created By:&nbsp;".$row[5]."</center></td>";
echo "<td><center><img src =".$row[1]." style=padding-bottom:5px></center></td>";
echo "</tr>";
}
echo "</table></center>";
}
else {
// no
// print status message
echo "No Contests Have Been Started.";
}


?>

This php file was then included as a variable (vb:raw) into a template of my choosing (pagination included!).

Christos Teriakis
22 Jul 2011, 08:02
Hello,



Any idea why this method even working fine in other (custom) pages, does not works in member.php? I've added a custom tab there (thank you again as that aricle is also yours), I used the same code that I had in my php file (copy & paste), but even if the navbar appears, it has:
Wrong number of pages: Show 2 instead of 3, in a list of 5 records having setup to show 2 records per page.
Clicking on 2nd page, or Last page, or Goto page, shows again the records of the 1st page and the highlighted link is of 1st page.Edited: 1 works ok... so only the links are not working.

Thank you

C.T.

Christos Teriakis
23 Jul 2011, 09:32
Just to post a followup. Finally I was able to find what causes the error, but now it left the harder, on how to solve it.

vBulletin when constructs a page adds page=xx at the end of link. The problem is when the link contains &tab=mytab#selectedtab. In this case seems that vB ignores anything after &tab=mytab#selectedtab, so it can't get the inbound page nbr. I tried placing &page=2 before &tab=mytab#selectedtab, and it works fine. Now I need to find a way to get the actual pagenumber to set it there as variable. $pagenumber does not works as it shows the same page.

C.T.

cellarius
23 Jul 2011, 09:58
When you construct the link, you can pass an anchor. The selected tab should be present as a variable ($selected_tab?), and since the anchor is always the same as the id, you should be able to completely construct the URL needed.

Christos Teriakis
23 Jul 2011, 10:13
When you construct the link, you can pass an anchor. The selected tab should be present as a variable ($selected_tab?), and since the anchor is always the same as the id, you should be able to completely construct the URL needed.

If I'm not asking a lot, and because I'm new to vB coding could you please help me a bit more? My current code is:

$pagenav = construct_page_nav($pagenumber, $perpage, $records, 'member.php?' . $vbulletin->session->vars['sessionurl'] . 'u='.$userid.'&action=1&tab=classifieds#classifieds');


** FIXED **

$pagenav = construct_page_nav($pagenumber, $perpage, $records, 'member.php?' . $vbulletin->session->vars['sessionurl'] . 'u='.$userid.'&action=1', '&tab=classifieds#classifieds');


Thank you

EquinoxWorld
29 Jul 2011, 01:19
Hello everyone, quick question;

What about multiple pagination instances on the same template for example?

I am having a bit of trouble with the second and third instances. I created 3 separate files and inserted them into the same template as plugins. Using three instances of:

<vb:if condition="$pagenav">
<div id="pagination_top">
{vb:raw pagenav}
</div>
</vb:if>

Like so:

<div id="test" class="block collapse">
<div class="blocksubhead">My First Place Trophies ({vb:raw oftw_firstplace_times})<a class="collapse" id="collapse_cel_dummy" href="{vb:raw relpath}#top" style="top: 5px;"><img src="{vb:stylevar imgdir_button}/collapse{vb:raw vbcollapse.collapseimg_cel_dummy_img}_40b.png" /></a></div>
<div class="blockrow" id="cel_dummy">
<center>{vb:raw oftw_get_mytrophies}</center>
<vb:if condition="$pagenav1">
<div id="pagination_top1" style="float: right; margin-bottom: 27px; margin-right: 5px;">
<center>{vb:raw pagenav1}</center>
</div>
</vb:if>
</div>
</div>
<div id="test" class="block collapse">
<div class="blocksubhead">My Second Place Trophies ({vb:raw oftw_secplace_times})<a class="collapse" id="collapse_cel_dummy2" href="{vb:raw relpath}#top" style="top: 5px;"><img src="{vb:stylevar imgdir_button}/collapse{vb:raw vbcollapse.collapseimg_cel_dummy_img}_40b.png" /></a></div>
<div class="blockrow" id="cel_dummy2">
<center>{vb:raw oftw_get_mysectrophies}</center>
<vb:if condition="$pagenav2">
<div id="pagination_top2" style="float: right; margin-bottom: 27px; margin-right: 5px;">
<center>{vb:raw pagenav2}</center>
</div>
</vb:if>
</div>
<div id="test" class="block collapse">
<div class="blocksubhead">My Third Place Trophies ({vb:raw oftw_thirdplace_times})<a class="collapse" id="collapse_cel_dummy3" href="{vb:raw relpath}#top" style="top: 5px;"><img src="{vb:stylevar imgdir_button}/collapse{vb:raw vbcollapse.collapseimg_cel_dummy_img}_40b.png" /></a></div>
<div class="blockrow" id="cel_dummy3">
<center>{vb:raw oftw_get_mythirdtrophies}</center>
<vb:if condition="$pagenav3">
<div id="pagination_top3" style="float: right; margin-bottom: 27px; margin-right: 5px;">
<center>{vb:raw pagenav3}</center>
</div>
</vb:if>
</div>

The PHP files are nearly identical except of course the $pagenav variable and some database reads, etc. The pagination for the first place trophies works perfect but the other two don't . When clicking on page 2 of the second place trophies it takes you to page 2 in the URL but in the pagination in stays in page 1 and shows the content of page 1, this for both second place and third place trophies. If anyone can help I can gladly post the php files if need be. :) Any info is good info. Thanks for your time guys.

cellarius
29 Jul 2011, 06:01
As far as I can see, the vB pagination classes won't work for multible instances per page. For what you seem to be after, I'd use some nifty jQuery AJAX thingy, to be honest, to get around all the page reloads the php method causes.

EquinoxWorld
29 Jul 2011, 12:32
As far as I can see, the vB pagination classes won't work for multible instances per page. For what you seem to be after, I'd use some nifty jQuery AJAX thingy, to be honest, to get around all the page reloads the php method causes.

Ahh , thanks Cellarius, I have been looking at some jquery pagination already but would have rather used vb built it mechanisms, oh well. I'll post here when I find something to share with everyone. Thanks for the feedback cel. :)

tounet
22 Jan 2013, 11:26
I run my script like this myscript.php? id = $ id how I could add
/ / URL parameters Cleaning
+ $ vbulletin-> input-> clean_array_gpc ('r', array (
++++ 'perpage' => TYPE_UINT,
++++ 'id' => TYPE_UINT,
++++ 'pagenumber' => TYPE_UINT,
++++
));
$ id = $ vbulletin-> GPC ['id'];

if I want to add a paging my results knowing that my script function well in this type of url: myscript.php? $ page = page & id = $ id

how to add $ id in this part of code:

/ / Display
$ pagenav construct_page_nav = (
++++ $ vbulletin-> GPC ['pagenumber']
++++ $ perpage,
++++
++++ $ cel_users ['users_count']
++++ 'myscript.php?' . $ vbulletin-> session-> vars ['sessionurl'], / / the pagenav-link
++++ '', / / To pass a portion or the second pagenav-link gets Directly above Appended to
++++ '', / / To pass an anchor
++++ '', / / ​​SEO-Link for thread, forum member ... pages - the make-links pagenav seo'ed if you use the paginator is One of Those
++++ '', / / ​​Array to pass linkinfo for SEO-Link Method
++++ '' / / Array to pass additional info for SEO-Link Method
);

thank you for your answers

BirdOPrey5
08 Sep 2013, 02:26
Glad I found this article... Still something new to learn. :)

sodagod
23 May 2015, 17:27
trying to implement this on an admin page.

cellarius
23 May 2015, 18:32
Won't work. AdminCP pages work completely different.

sodagod
23 May 2015, 18:45
the main query works, but construct_page_nav doesnt, looking into just using nextpage for admin pages.

edits....

https://www.vbulletin.org/forum/showthread.php?t=200413

I used this code for the admincp results.

the code in this thread works great for normal pages tho.