Hi,

in header of a view I want to show how much results another view gets. I tried it by putting following code into the view's header (php input format activated):

<?php
$my_view = views_get_view( 'count_flights' );
$my_view->execute();
$my_view_sum= count($my_view->result);
?>
<p style="font-weight: bold; text-align: right; color: red">Sum: <?php print $my_view_sum; ?></p>

When I have a look at my_view in preview it shows me up to 23 results - but when I want to count the results in the above way it brings just 10 results. I had a look at $my_view bei print_r($my_view) and it actually has just 10 nodes in it although the "items to display" is set to unlimited. Does anyone has an idea what can lead to this issue????

Best,
Tobias

Comments

tobiberlin’s picture

Status: Active » Closed (fixed)

Ok found the solution: you have to set the pager manually before executing the view:

<?php
$my_view = views_get_view( 'count_flights' );
$my_view->pager['items_per_page'] = 0;
$my_view->execute();
$my_view_sum= count($my_view->result);
?>

leoklein’s picture

Thanks. Great example that helped me out.