first import
This commit is contained in:
16
sites/all/modules/views/help/get-total-rows.html
Normal file
16
sites/all/modules/views/help/get-total-rows.html
Normal file
@@ -0,0 +1,16 @@
|
||||
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>
|
||||
<?php
|
||||
function my_module_views_pre_execute(&$view) {
|
||||
if ($view->name == 'my_view' && $view->current_display == 'my_display') {
|
||||
$view->get_total_rows = TRUE;
|
||||
}
|
||||
}
|
||||
?>
|
||||
</pre>
|
Reference in New Issue
Block a user