We can use drupal core pagination in our customized module using following steps:
function xyz(){
$limit = 10;
$query = "select fields from table";
$count = " select count(*) from table";
$result = pager_query($query,$limit,0,$count);
while($arr = db_fetch_array($result))
{
$dataArr[] = $arr;
}
//function is defined in pager.inc
$pager = theme_pager($limit);
$block_content = theme('tpl_name',$dataArr,$pager);
return $block_content;
}
//in theme funtion
'tpl_name' => array(
'template' => 'tpl_name',
'arguments' => array('dataArr'=>null,'pager'=>null),
),
//in tpl file write following line in last
<div> <?php echo $pager; ?> </div>
//Now pagination is quite simple
|
My Blog Title
|