I looked around a bit, but couldn't find a built-in way of producing:

[Results 20 to 30 of 64]

sort of header to my paged view.
So here's how I did it. Including the exploratory steps.

  1. Locate your view renderer and create a theme for it.
    In my case, I edited the view, and clicked 'theme info'.
    My view called "topiclist" was currently using "Display output: views-view.tpl.php".
    The views UI told me I could instead use "views-view--topiclist.tpl.php" so I copied views-view.tpl.php from the views module directory into my theme and renamed it as suggested. (and re-scanned directories using the provided button as advised)
    This is normal views theming. I now have control of that level of rendering.
  2. Figure out what you are working with
    That page had a lot of stuff I didn't recognize or think I needed, but I didn't remove anything. Instead I made sure devel.module was on and added
    dpm($variables);
    

    into that page for debugging.

  3. Display what you want
    That showed me everything available for messing around with. I figured the $view->pager was a useful place to start, and after a few tests produced the following code:
      $start = ($view->pager['current_page'] * $view->pager['items_per_page']) + 1;
      $finish = $start + count($view->result) - 1;
      $total = $view->total_rows;
      echo "$start to $finish of $total";
    

    Which I put inside the view display, near the 'view-header'. (and removed the debug line)

Done!

There are other methods, possibly by inserting the same code into the actual header field of the view, but this was the answer I needed today.

Note

The snippet works, but only if you use it in the tpl.php file. The pager variables aren't available if you use the code in your 'header' part in the Views 2 user interface.

Comments

pkiff’s picture

If you want to insert something like this into your View 'header', you could try the alternate code discussed in Count view query results with footer PHP snippet [drupal.org].

This alternate code requires that you have PHP Code insertion enabled as an input format, and that you have admin rights to insert PHP code.

It worked well for me on Drupal 6.15 with Views 6.x-2.8.

Phil.