Projet

Général

Profil

Paste
Télécharger (772 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / help / get-total-rows.html @ 7547bb19

1
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.
2

    
3
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.
4
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.
5

    
6
This code will help you do that.
7

    
8
<pre>
9
&lt;?php
10
function my_module_views_pre_execute(&$view) {
11
  if ($view->name == 'my_view' && $view->current_display == 'my_display') {
12
    $view->get_total_rows = TRUE;
13
  }
14
}
15
?&gt;
16
</pre>