function yandex_metrics_reports_obtain_page_title in Yandex.Metrics 7.2
Same name and namespace in other branches
- 8.2 yandex_metrics_reports/yandex_metrics_reports.module \yandex_metrics_reports_obtain_page_title()
Obtain page title by path and language if possible.
Parameters
string $path:
string $language:
Return value
string
2 calls to yandex_metrics_reports_obtain_page_title()
- YandexMetricsReportsTestCase::testObtainPageTitle in yandex_metrics_reports/
yandex_metrics_reports.test - Test for yandex_metrics_reports_obtain_page_title() function.
- yandex_metrics_reports_save_popular_content in yandex_metrics_reports/
yandex_metrics_reports.module - Fetch Popuplar content from Yandex.metrika and save it to the database.
File
- yandex_metrics_reports/
yandex_metrics_reports.module, line 452 - The main code of Yandex.Metrics Reports module.
Code
function yandex_metrics_reports_obtain_page_title($path, $language = 'en') {
$path = ltrim($path, '/');
$site_frontpage = variable_get('site_frontpage', 'node');
if (empty($path) || $path == $site_frontpage || $path == $language . '/' . $site_frontpage) {
return variable_get('site_name', t('Front page', array(), array(
'langcode' => $language,
)));
}
// Get normal path, like node/1.
$normal_path = drupal_get_normal_path($path, $language);
$item = menu_get_item($normal_path);
if (empty($item) || empty($item['title'])) {
return $path;
}
return $item['title'];
}