Recipe 78: Total Item count
You may add the total node count to the view title by performing a theme override of the theme_views_view
function.
Copy the
theme_views_view
function intotemplate.php
.Rename the function to
phptemplate_views_view_<VIEWNAME>
.(Be sure to substitute the name of your view.)
Change this section, near the top of the function:
if ($type == 'page') { drupal_set_title(filter_xss_admin(views_get_title($view, 'page'))); views_set_breadcrumb($view); }
To this:
if ($type == 'page') { drupal_set_title(filter_xss_admin(views_get_title($view, 'page')) .' ('. $view->total_rows .')'); views_set_breadcrumb($view); }
Recipe notes
$view->total row
only exists if the view has a pager. If there is no pager, use$view->num_rows
, instead.Tip
The
$view->total_row
variable does not appear when we clone a view. So how do we know of its existence? One way is to temporarily add the following code to the Views header (be sure to set the input...