Sign up ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I have several views on my Drupal site. I also have a page that links to those views. I would like to see the number of items (e.g. the number of pages) that are listed in each view:

  • link to foobar view [5 items]
  • link to other view [0 items]

Is there an easy way to do this. I suppose I will need embedded PHP for this, but I would like to avoid huge SQL statements embedded in my linking page.

share|improve this question

migrated from Jun 21 '11 at 11:54

This question came from our site for pro webmasters.

1 Answer 1

up vote 3 down vote accepted

You can get the amount of results in a view using their API calls.

$views = view::load("viewname");
$view->set_display('default'); //optional, could be default, OR the name of a specific display
echo count($views->result);

I tested this on views 3 (the current version). For further reading, check out It's written for views 2, but still relevant.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.