I'm wondering if it's possible to display, ideally in a header of a view page, the number of nodes returned by the view.

Using the views theme wizard I have been able to get the number of nodes returned by adding print $view->total_rows; to the template, but then that shows up for each node returned by the view. I tried putting the same code into the header of the view but couldn't get anything to come up.

Comments

rajaka’s picture

Hi, I had exactly the same issue and here's how I solved it for my case.


print ( views_get_view('meeting')->total_rows );

Where 'meeting' is the name of needed view. So, views_get_view('meeting') actually returns $view. It seems that Header and Footer's variable scopes don't contain direct reference to $view, so you should get it first. I hope this will help :)

Flash Teh Ripper
ghumpley’s picture

Ah sweetness! Works like a charm, THANKS!!!

morisy’s picture

I'm using Drupal 6/Views 2, and this is the exact functionality I want but I can't get the snippet to work when I embed it in a node. Do the same API calls work?