function yandex_metrics_page_build in Yandex.Metrics 8.2
Same name and namespace in other branches
- 7.3 yandex_metrics.module \yandex_metrics_page_build()
- 7 yandex_metrics.module \yandex_metrics_page_build()
- 7.2 yandex_metrics.module \yandex_metrics_page_build()
Implements hook_page_build(). Adds Yandex.Metrics counter code to the site footer.
File
- ./
yandex_metrics.module, line 22 - The main code of Yandex.Metrics Counter module.
Code
function yandex_metrics_page_build(&$page) {
$yandex_metrics_counter_code = Drupal::config('yandex_metrics.settings')
->get('counter_code');
if (!empty($yandex_metrics_counter_code) && yandex_metrics_show_counter() && yandex_metrics_show_counter_for_role()) {
$path = drupal_get_path('module', 'yandex_metrics');
$page['page_bottom']['yandex_metrics'] = array(
'#type' => 'markup',
'#markup' => '<div class="ym-counter">' . $yandex_metrics_counter_code . '</div>',
'#attached' => array(
'css' => array(
$path . '/css/yandex_metrics.css',
),
),
);
}
}