0

I used the below code but it gives me error. Below is my code:
if(isset($_GET['tid'])) { $id=($_GET['tid']); $query = new EntityFieldQuery(); $query->entityCondition('entity_type', 'node'); $query->entityCondition('bundle', 'escorts_product'); $query->propertyCondition('status', 1); $query->fieldCondition('field_product_sub_cat', 'tid', $id,'='); $result = $query->execute(); $total=count($result); function pager_default_initialize($total, $limit = 2, $element = 0) { global $pager_page_array, $pager_total, $pager_total_items; $page = pager_find_page($element); $pager_total_items[$element] = $total;//total items $pager_total[$element] = ceil($pager_total_items[$element] / $limit); $pager_page_array[$element] = max(0, min($page, ((int) $pager_total[$element]) -1)); $pager_limits[$element] = $limit; return $pager_page_array[$element]; //print "<pre>";print_r($pager_page_array[$element]); } print theme('pager', array('quantity',count($result)));
error on this line
function pager_default_initialize($total, $limit = 2, $element = 0) ,can anyone please guide me?

2
  • Can you please specify what error you are getting?
    – Bipin K
    Mar 17, 2015 at 10:14
  • "Can not redeclare pager_default_initialize", I think it is already declared just need to call this, I also call this by just writing pager_default_initialize($total, $limit = 2, $element = 0); , error is not appearing now but also not paging?
    – nomeer
    Mar 17, 2015 at 10:22

1 Answer 1

1

You have missed a parenthesis } before the line: function pager_default_initialize($total, $limit = 2, $element = 0).

Please put it and check the result.

3
  • Thanku @Nilesh, error is fixed but paging not appearing.
    – nomeer
    Mar 17, 2015 at 10:31
  • You are welcome, Here you have define the function: function pager_default_initialize($total, $limit = 2, $element = 0) but where you have called that function? You will need to call it at appropriate place.
    – Nilesh
    Mar 17, 2015 at 10:41
  • I have my custom template file product-categoies.tpl.php, after defining I used $offset = ($page) * $limit; $last = ($offset + $limit <$total)?$offset+$limit:$total; $pg=printtheme('pager',array('quantity',count($result)));
    – nomeer
    Mar 17, 2015 at 10:46

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