Drupal - Custom Module Pagination
by admin on Aug.18, 2009, under Linux Blerg
Here is an useful tutorial for enabling pagination in a drupal module by calling one of drupal theme api.
Solution :
The simple concept is queries per page,
Previously I have the query as,
$query = “SELECT fields FROM table ORDER BY id DESC”;
db_query( $query)
I had Replaced it with,
$query = “SELECT fields FROM table ORDER BY id DESC”;
$sql_count = “SELECT COUNT(*) FROM table ORDER BY id DESC “;
$sql_count = db_rewrite_sql($sql_count);
$query1 = db_rewrite_sql($query);
$result = pager_query($query1, 6, 0,$sql_count);
And add the following lines before you return output,
theme(’pager’, NULL, 6, 0);
(Eg)
$output .= theme(’pager’, NULL, 6, 0);
return $output;
Thus I can get pagination ,where 6 queries executed per page.
taken from : http://www.devhunters.com/php-cgi-asp-server-side-programming/12403-getting-pagination-drupal-developed-modules.html
-= end transmission =-


















November 5th, 2009 on 12:41 pm
Your blog is so informative
January 22nd, 2010 on 6:48 am
Very good.