Without writing using any Drupal db functions, how can I display the total/count/number of results of a view in its Header?
Do you not mean these predefined value(s) in the Header area ?
You could count the number of rows using PHP in views_pre_render() ... but I bet this is what the above is doing already ....
No need to use any php code.
you need the token module to be enabled along with the view of course.
1) Go to the view in question. 2) Click "Add" next to either "Header" or "Footer" in the center of the view. 3) Choose "Global: Result summary" 4) Click "Apply (All displays)" 5) On the next screen, you can chose tokens to put into the "Display" area. Here are the tokens you can use:
@start -- the initial record number in the set @end -- the last record number in the set @total -- the total records in the set @name -- the human-readable name of the view @per_page -- the number of items per page @current_page -- the current page number @current_record_count -- the current page record count @page_count -- the total page count
Once you've chosen your options, click "Apply (All displays)".
7) You can put something like: Displaying @start - @end of @total.
Hope it helps.
Warning: this tip requires enabling the core
PHP Filter module, which opens up security concerns that could potentially allow the entry of PHP code into the site in ways that you may not want, if permissions are not configured correctly.
Here is how using the core
PHP Filter module:
- In your view, add a header element of type
Then add this snippet to text/php field in the header
<?php echo $view->total_rows; ?>
That should do it. There are a tonne more variables in the
Edit: As @Motot suggested, added security note.