Add [Results x to y out of z] info to a view

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

    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;

Configuring PHP to resolve the "Error sending email" message

This article is based on experience with a Linux system running an Apache web server, but the problems and solutions apply to many other Linux and non-Linux environments.

Navigate - a 3 minute whirlwind tour

On, there is a quick, 3-minute whirlwind tour of the Navigate module, which uses tools like menu search and bookmarking to make navigating through Drupal as quick and effective as possible.

Display all top-level taxonomy terms

This PHP snippet displays all top-level taxonomy terms in a page or a block.

For each term, the count of sub-terms is displayed.

The code is using the taxonomy API, so it's compatible with taxonomy_redirect (verified). It should also be compatible with other add-on modules which change the term path.


Stub: This section contains examples of using FormAPI, and explanations of those examples.

Inner workings

Stub: This page will become a complete(ish) conceptual overview of FormAPI's inner workings, exploring what functions like drupal_get_form do etc.


Subscribe with RSS Subscribe to RSS - Programmers