function _yandex_metrics_popular_content in Yandex.Metrics 7
Same name and namespace in other branches
- 6 yandex_metrics.module \_yandex_metrics_popular_content()
The function generates the table of popular content.
Parameters
string $counter_id:
string $filter:
2 calls to _yandex_metrics_popular_content()
- yandex_metrics_ajax in ./
yandex_metrics.module - Menu callback; outputs content of one of the 4 reports. It is intended for AJAX calls.
- yandex_metrics_report in ./
yandex_metrics.module - Menu callback; displays a Summary page containing reports and charts.
File
- ./
yandex_metrics.module, line 557 - The main code of Yandex.Metrics module.
Code
function _yandex_metrics_popular_content($counter_id, $filter) {
$output = '';
$date_range = _yandex_metrics_filter_to_date_range($filter);
$parameters = array(
'id' => $counter_id,
'date1' => $date_range['start_date'],
'date2' => $date_range['end_date'],
);
$report_content = yandex_metrics_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', array(
'header' => $header,
'rows' => $data,
'caption' => t("Popular Content"),
));
}