function yandex_metrics_reports_popular_content in Yandex.Metrics 8.3
Same name and namespace in other branches
- 8.2 yandex_metrics_reports/yandex_metrics_reports.reports.inc \yandex_metrics_reports_popular_content()
- 7.3 yandex_metrics_reports/yandex_metrics_reports.reports.inc \yandex_metrics_reports_popular_content()
- 7.2 yandex_metrics_reports/yandex_metrics_reports.reports.inc \yandex_metrics_reports_popular_content()
The function generates the table of popular content.
Parameters
string $counter_id: Counter id.
string $filter: Date range filter.
3 string references to 'yandex_metrics_reports_popular_content'
- yandex_metrics_reports_update_7202 in yandex_metrics_reports/
yandex_metrics_reports.install - Enlarge URL field size for popular content database table.
- yandex_metrics_reports_update_7300 in yandex_metrics_reports/
yandex_metrics_reports.install - Upgrade from 7.x-2.x to 7.x-3.x.
- yandex_metrics_reports_yandex_metrics_reports_list in yandex_metrics_reports/
yandex_metrics_reports.module - Implements hook_yandex_metrics_reports_list().
File
- yandex_metrics_reports/
yandex_metrics_reports.reports.inc, line 190 - Report callbacks for Yandex.Metrics Reports module.
Code
function yandex_metrics_reports_popular_content($counter_id, $filter) {
$date_range = yandex_metrics_reports_filter_to_date_range($filter);
$parameters = array(
'id' => $counter_id,
'date1' => $date_range['start_date'],
'date2' => $date_range['end_date'],
);
$report_content = yandex_metrics_reports_retreive_data('/stat/content/popular', $parameters);
$content = json_decode($report_content->data);
if (empty($content->data)) {
return t('There is no information about popular content for the selected date range.');
}
$header = array(
t('URL'),
t('Page Views'),
);
$data = array();
$i = 1;
foreach ($content->data as $value) {
if ($i > YANDEX_METRICS_REPORTS_POPULAR_CONTENT_COUNT) {
break;
}
$page_views = (int) $value->page_views;
$data[] = array(
l($value->url, $value->url, array(
'attributes' => array(
'target' => '_blank',
),
)),
$page_views,
);
$i++;
}
return theme('table', array(
'header' => $header,
'rows' => $data,
'caption' => t("Popular Content"),
));
}