Drupal 7 pager from module fuction not displaying in page.tpl I have a function mymodule_submissions in my module which fetches rows from mymodule_table and prints as table theme with pager. Its working fine if I define a menu link in my module to call that function. Pager not printing when I call the same function from a page.tpl. 

function mymodule_submissions() { 

   $query = db_select('mymodule_table', 'uf');
   $query = $query-&gt;condition('uid', $user-&gt;uid)
             -&gt;fields('mytable', array('id', 'name', 'createdtime'))
             -&gt;orderBy('createdtime', 'DESC')-&gt;limit(3);
   $results = $query-&gt;execute();
   $header = array('ID','Name','Created Time');

   $rows = array();

   foreach($results As $result) {
      $rows[] = array( $result -&gt; id, $result -&gt; name, $result -&gt; createdtime,);
   }

   $output .= theme('table', array('header' =&gt; $header, 'rows' =&gt; $rows,) );

   $output .= theme('pager');
   return $output;
}


From page.tpl, I am calling this function link below

print render(mymodule_submissions());


Anything I'm doing wrong?
You just need to add -&gt;extend('PagerDefault');

$query = db_select('mymodule_table', 'uf')-&gt;extend('PagerDefault');


I find the examples module really useful.  They have a pager example.

For what its worth I think using the Drupal db API with theming is a perfectly valid way forward that has a lot of strengths: it's efficient, flexible, powerful and you can put it in version control.  Obviously you should use the best thing for the situation.