MyBB Community Forums

Full Version: Please How Can I Add Pagination To This Plugin
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I Want to add pagination to this
plugin:

NewThread Plugin

its a plugin that displays recent
thread on index, anyone have a
solution? please post it. Thanks
Just to ensure your desire...
Do you wish to list threads including categories and subforums in breadcrumb style like the following?

<a>Category</a> / <a>Forum</a> / <a>Subforum</a> / <a>Thread Title</a>

Idea:
To generate the breadcrumb trails, it may be possible to use the functions given by the board software:
https://crossreference.mybb.de/nav.html?....html#l255

[ExiTuS]
actually such plugins are not meant to show lot of results !
perhaps you might be interested in using active threads plugin
@m
does this one (Active thread plugin) have pagination...?

(2020-02-22, 02:57 AM).m. Wrote: [ -> ]actually such plugins are not meant to show lot of results !
perhaps you might be interested in using active threads plugin

does it have pagination... i mean dis active threads plugin?
^ yes, it uses pagination for its results.
Quote:paginated at 20 threads per page
Just for reference, pagination with items stored in the database works like this:

  1. Execute a query to determine the total amount of items stored.
    $query = $db->simple_select({your_table}, 'COUNT(id) AS totalItems');
    $totalItems = $db->fetch_field($query, 'totalItems');
    


  2. Calculate the total pages: $totalPages = ceil($totalItems / $perPage)
  3. Ensure that the passed page number is in range.
  4. Calculate the starting point using the current page number and amount per page: $start = ($pageNumber - 1) * $perPage
  5. Use this info to determine if pagination is needed:
     if ($totalItems > $perPage) {
     	$pagination = draw_admin_pagination($pageNumber, $perPage, $totalItems, $url);
    	 echo($pagination);
     }
    


  6. Now query again, this time using the calculated info as parameters:
    $query = $db->simple_select({your_table}, '*', '', array("limit" => $perPage, "limit_start" => $start));
    


Note: You need not gather all of the information in the first query. It can be simplified as seen above, by removing JOINs that are not essential to the process.
(2020-02-25, 06:55 PM)Wildcard Wrote: [ -> ]Just for reference, pagination with items stored in the database works like this:

  1. Execute a query to determine the total amount of items stored.
    $query = $db->simple_select({your_table}, 'COUNT(id) AS totalItems');
    $totalItems = $db->fetch_field($query, 'totalItems');
    


  2. Calculate the total pages: $totalPages = ceil($totalItems / $perPage)
  3. Ensure that the passed page number is in range.
  4. Calculate the starting point using the current page number and amount per page: $start = ($pageNumber - 1) * $perPage
  5. Use this info to determine if pagination is needed:
     if ($totalItems > $perPage) {
     	$pagination = draw_admin_pagination($pageNumber, $perPage, $totalItems, $url);
    	 echo($pagination);
     }
    


  6. Now query again, this time using the calculated info as parameters:
    $query = $db->simple_select({your_table}, '*', '', array("limit" => $perPage, "limit_start" => $start));
    


Note: You need not gather all of the information in the first query. It can be simplified as seen above, by removing JOINs that are not essential to the process.


please can u help fix it am not good at coding