function breadcrumb_manager_get_title in Breadcrumb Manager 7
Helper function: retrieve correct title by path.
Parameters
string $path: The path to be checked.
Return value
string The page title.
2 calls to breadcrumb_manager_get_title()
- breadcrumb_manager_is_title_required in ./
breadcrumb_manager.module - Check if the current page title is missing or in blacklist.
- breadcrumb_manager_set_breadcrumb in ./
breadcrumb_manager.module - Magic function: Evaluates correct breadcrumb from the given path.
File
- ./
breadcrumb_manager.module, line 175 - Code for Breadcrumb Manager module.
Code
function breadcrumb_manager_get_title($path) {
$titles =& drupal_static(__FUNCTION__);
if (!isset($titles[$path])) {
$title = '';
$source = db_select('url_alias', 'ua')
->fields('ua', array(
'source',
'language',
))
->condition('ua.alias', $path)
->execute()
->fetchObject();
if (!empty($source)) {
$source_arr = explode('/', $source->source);
switch ($source_arr[0]) {
case 'node':
$node = node_load($source_arr[1]);
$title = $node->title;
break;
case 'taxonomy':
$term = taxonomy_term_load($source_arr[2]);
$title = $term->name;
break;
}
if (empty($title)) {
$title = '';
$source_path = drupal_lookup_path('source', $source->source);
if (empty($source_path)) {
$language = module_exists('i18n_menu') ? $source->language : NULL;
$title = _breadcrumb_manager_get_title_by_menu_link($source->source, $language);
}
}
$titles[$path] = $title;
}
else {
// First of all: try to get title by language if i18n_menu exists.
$language = module_exists('i18n_menu') ? $GLOBALS['language']->language : NULL;
$title = _breadcrumb_manager_get_title_by_menu_link($path, $language);
// In case of failure try to get title without language.
if (empty($title)) {
$title = _breadcrumb_manager_get_title_by_menu_link($path);
}
// Finally try to extract title from menu router.
if (empty($title)) {
$title = _breadcrumb_manager_get_title_by_menu_router($path);
}
$titles[$path] = t($title);
}
}
return $titles[$path];
}