You are here

function views_blogspot_archive_add_count in Views Blogspot Archive 8

Add counts value to year and month.

Parameters

array $results: Array contain views result.

Return value

array An results array.

1 call to views_blogspot_archive_add_count()
template_preprocess_views_blogspot_archive_view_archive in templates/views_blogspot_archive.theme.inc
Prepares variables for view templates.

File

templates/views_blogspot_archive.theme.inc, line 143
Preprocessors and helper functions to make theming easier.

Code

function views_blogspot_archive_add_count(array $results) {
  if (!empty($results)) {
    foreach ($results as $year => $month) {
      $year_count = 0;
      foreach ($month as $key => $title) {
        $count = count($title, COUNT_RECURSIVE);
        $results[$year][$key . ' (' . $count . ')'] = $results[$year][$key];
        unset($results[$year][$key]);
        $year_count += $count;
      }
      $results[$year . ' (' . $year_count . ')'] = $results[$year];
      unset($results[$year]);
    }
  }
  return $results;
}