Drupal - EntityFieldQuery display pager
I suspect the only thing you're missing is adding the return from theme('pager')
to the content you're building.
This is a small example that shows teasers for all nodes in the system, with 10 per page. You would use this in a page callback function:
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
->pager(10);
$results = $query->execute();
$content = node_view_multiple(node_load_multiple(array_keys($results['node'])));
$build = array(
'content' => $content,
'pager' => array(
'#theme' => 'pager',
'#weight' => 10
)
);
return $build;
More specific based on your comments:
if ($type == 21) {
$query = new EntityFieldQuery();
$entities = $query->entityCondition('entity_type', 'node')
->propertyCondition('type', 'product')
->fieldCondition('field_razred', 'tid', array (607,608,609,610), 'IN')
->pager(10) // this is the bit you're missing
->execute();
$nodes = node_load_multiple(array_keys($entities['node']));
print render(node_view_multiple($nodes, 'teaser')) . theme('pager');
}
Also been having some trouble with this - debugging statements initializePager showed that the optional $element parameter was being set to 1 rather than 0.
If there is only one pager being displayed, try setting it explicitly to 0.
$query->pager(10, 0);