HEX
Server: Apache
System: Linux webm010.cluster103.gra.hosting.ovh.net 6.18.42-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Wed Aug 5 15:59:48 CEST 2026 x86_64
User: iestorre (46869)
PHP: 8.0.30
Disabled: _dyuweyrj4,_dyuweyrj4r,dl
Upload Files
File: /home/iestorre/www2/modules/views/help/get-total-rows.html
The flag $view->get_total_rows is used to force the query of the view to calculate the total number of results of the set.

This parameter is TRUE by default in views that get all the results (no limit) or those which have a pager, so you always have the $view->total_rows variable populated in those cases.
But when you have a view that gets only a given number of results and no pager, the count query is not executed by default so you have to force it, i.e. in the hook_views_pre_execute so you have $view->total_rows populated for later use.

This code will help you do that.

<pre>
&lt;?php
function my_module_views_pre_execute(&$view) {
  if ($view->name == 'my_view' && $view->current_display == 'my_display') {
    $view->get_total_rows = TRUE;
  }
}
?&gt;
</pre>