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?
1 Answer
You have missed a parenthesis } before the line: function pager_default_initialize($total, $limit = 2, $element = 0).
Please put it and check the result.
-
-
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.– NileshMar 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)));
– nomeerMar 17, 2015 at 10:46
pager_default_initialize($total, $limit = 2, $element = 0);
, error is not appearing now but also not paging?