function _yandex_metrics_reports_popular_content in Yandex.Metrics 6.2
The function generates the table of popular content.
Parameters
string $counter_id:
string $filter:
1 string reference to '_yandex_metrics_reports_popular_content'
- 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.module, line 506 - The main code of Yandex.Metrics Reports module.
Code
function _yandex_metrics_reports_popular_content($counter_id, $filter) {
$output = '';
$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_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', $header, $data, array(), t("Popular Content"));
}