function language_hierarchy_preprocess_node in Language Hierarchy 2.x
Same name and namespace in other branches
- 8 language_hierarchy.module \language_hierarchy_preprocess_node()
Implements hook_preprocess_node().
File
- ./
language_hierarchy.module, line 527 - Add sublanguage handling functionality to Drupal.
Code
function language_hierarchy_preprocess_node(&$variables) {
if (!empty($variables['url'])) {
/** @var \Drupal\node\NodeInterface $node */
$node = $variables['node'];
$url = $variables['url'];
if (is_string($url)) {
$url_obj = $node
->toUrl();
if ($url_obj
->toString() === $url) {
$url = $url_obj;
}
}
if ($url instanceof Url) {
$variables['url'] = language_hierarchy_fix_url_from_fallback($url, $node)
->toString();
}
}
}