MyBB Community Forums

Full Version: How to fetch pagination pages URLs from sql MYBB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there a way to fetch from SQL all thread and forums pagination pages URLs?

site.com/thread-title not what I want.
site.com/thread-title?page=1 is what I want.
Set a limit and use vars to get values inside that to get your list of pages taken first and las valus on limit and pages with divisor if value is greater than second argument in first value of the limit.

I want to say limit $value, $second_value

And on that way you can set the pagination
The problem is that URLs are not created by the SQL but by the PHP. I know how to create forum and thread link but have no idea how to create pagination link!
Quote:$query = $db->simple_select("sometable", "COUNT(pid) AS results"); // change pid to your primary key field
$totalcount = $db->fetch_field($query, "results");
$perpage = 15;
$pages = $totalcount / $perpage;
$pages = ceil($pages);
$currentpage = (int) $mybb->input['page'];

/* some PHP to generate your page */

$multipage = multipage($totalcount, $perpage, $currentpage, "yourfile.php?url=whatever_your_url_path_is");

You will then be able to use {$multipage} in your templates. As far as actually selecting items from the database to take into account your current page...

Quote:$perpage = 15;
$currentpage = (int) $mybb->input['page'];

if ($totalpages > 0) {
$offset = ($currentpage - 1) * $perpage; // forgive the lack of indentation, mybb keeps stripping out the tab characters
}
else {
$offset = 0;
}

$result = $db->query("SELECT * FROM ".TABLE_PREFIX."sometable ORDER BY pid ASC LIMIT {$offset}, {$perpage}");

I haven't really tested this, but that's generally how MyBB handles pagination. You will then be able to select pages via yourfile.php?url=someURL&page=5.
Thanks buddy very much that is awesome. Will definitely use your code in my projects.

However i am looking for a way to create a list or a sitemap containing only pagination pages?