Skip to Content Skip to Menu

Can someone explain the paging API for articles?

  • bjraines
  • bjraines
  • OFFLINE
  • Posts: 87
  • Thanks: 0
  • Karma: 2
17 years 7 months ago #32723 by bjraines
I really need to paginiate articles but I cannot figure out how to use the API. Please help.

Please Log in or Create an account to join the conversation.

  • p9939068
  • p9939068
  • OFFLINE
  • Posts: 186
  • Thanks: 0
  • Karma: 117
17 years 7 months ago #32731 by p9939068
the pagination API has 3 params: the limit (upper limit), limitstart (lower limit), and count (total count of records)

To get the value of limit:
[code:1]
$limit = intval( $mainframe->getUserStateFromRequest( "viewlistlimit", 'limit', $mosConfig_list_limit ) );
[/code:1]
To get the value of limitstart
[code:1]
$limitstart = intval( $mainframe->getUserStateFromRequest( "view{$option}limitstart", 'limitstart', 0 ) );
[/code:1]
To get the value of count, do a SELECT COUNT on the table that keeps the records that you wish to paginate.

You will also need to call pageNavigation.php by:
[code:1]
require_once( $mosConfig_absolute_path . '/administrator/includes/pageNavigation.php' );
[/code:1]

Then create the paging object:
[code:1]
$pageNav = new mosPageNav( $total, $limitstart, $limit );
[/code:1]

To select the records to display, do the usual select statement and include "LIMIT $limitstart, $limit".

To output the Display # dropdown menu you see in some components admin backend:
[code:1]
<?php echo $pageNav->getListFooter(); ?>[/code:1]


Mike Feng
Creator of SIMGallery, SIMAnswers, and ParaInvite
www.simbunch.com
twitter.com/simbunch

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum