Upgrade Your Drupal Skills
We trained 1,000+ Drupal Developers over the last decade.
See Advanced Courses NAH, I know EnoughCount the Total Number of Results in Drupal Views
One of our members wondered if it was possible to automatically calculate the number of results displayed in a View.
Yes, this is definitely possible. To make this work, you will need Views, plus also the Token module installed.
Start with a long list of entries in a View, as in the image below:
- Go to edit the view.
- Click "Add" next to either "Header" or "Footer" in the center of the view:
- Choose "Global: Result summary"
- Click "Apply (All displays)"
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)".
Save your view and you'll now see that the number of results is automatically calculated:
About Drupal Sun
Drupal Sun is an Evolving Web project. It allows you to:
- Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
- Facet based on tags, author, or feed
- Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
- View the entire article text inline, or in the context of the site where it was created
See the blog post at Evolving Web