function simplenews_statistics_handler_clicks::render in Simplenews Statistics 7
Same name and namespace in other branches
- 7.2 includes/views/handlers/simplenews_statistics_handler_clicks.inc \simplenews_statistics_handler_clicks::render()
Renders the field handler.
Overrides views_handler_field::render
File
- includes/
views/ handlers/ simplenews_statistics_handler_clicks.inc, line 61 - Definition of simplenews_statistics_handler_clicks.
Class
- simplenews_statistics_handler_clicks
- Description.
Code
function render($values) {
$field = $this->real_field;
$precision = intval($this->options['ctr_precision']);
$unique_opens = simplenews_statistics_count_opens($values->nid, TRUE);
if ($field == 'click_count') {
$click_count = simplenews_statistics_count_clicks($values->nid);
}
else {
$click_count = simplenews_statistics_count_clicks($values->nid, TRUE);
}
if ($field == 'ctr' && $unique_opens > 0) {
return round($click_count / $unique_opens * 100, $precision) . '%';
}
elseif ($field == 'ctr' && $unique_opens == 0) {
return t('N/A');
}
return $click_count;
}