0

I used this code to get a pager.

   if (isset($_GET['tid'])) {
     $id=($_GET['tid']);
     $query = new EntityFieldQuery();
     $query->entityCondition('entity_type', 'node');
     $query->entityCondition('bundle', 'escorts_product');
     $query->pager(2,1);
     $query->propertyCondition('status', 1);
     $query->fieldCondition('field_product_sub_cat', 'tid', $id,'=');
     $result = $query->execute();
    //print "<pre>";print_r($result);
    }

When I used print "<pre>";print_r($result), it gave me 2 results on y page, whereas I added more than 2; this is right.

How should I get links for next page and also previous, next? Is there any other way to get a pager?

1 Answer 1

0

To get the links for the next/previous pages you need to use theme('pager').

On this post you can find an example of that implementation.

2
  • Thanku @gerzenstl, I am using node_load() function after getting the nids ( $nids = array_keys($result['node']);)?but the link you have mentioned is based on node_load_multiple(), so can you elaborate please how should I achieve this using node_load()? I
    – nomeer
    Commented Mar 17, 2015 at 3:56
  • Cool! Yes it works independently if you use node_load() or node_load_multiple(). All the calculation for the pagination it's done mostly by the pager() method.
    – gerzenstl
    Commented Mar 18, 2015 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.