Project D

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 =-

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • LinkedIn
  • Slashdot
  • StumbleUpon
  • blinkbits
  • eKudos
  • Live
  • Share/Save/Bookmark

2 Comments for this entry

Leave a Reply

You must be logged in to post a comment.

RSS Fresh Ebuild