function opigno_learning_path_preprocess_block in Opigno Learning path 8
Same name and namespace in other branches
- 3.x opigno_learning_path.module \opigno_learning_path_preprocess_block()
Implements hook_preprocess_HOOK() for block.
File
- ./
opigno_learning_path.module, line 591 - Contains opigno_learning_path.module.
Code
function opigno_learning_path_preprocess_block(&$variables) {
$route = \Drupal::routeMatch();
// Change pages title.
if ($variables['plugin_id'] == 'page_title_block') {
if ($route
->getRouteName() == 'entity.taxonomy_vocabulary.overview_form') {
$parameter = $route
->getParameter('taxonomy_vocabulary');
if ($parameter && $parameter
->id() == 'learning_path_category') {
$variables['content']['#title'] = t('Manage training categories');
}
}
elseif ($route
->getRouteName() == 'opigno_learning_path.learning_path_settings') {
$variables['content']['#title'] = t('Manage training settings');
}
}
// Unset empty links for opigno admin menu.
if ($variables["derivative_plugin_id"] == "opigno-admin") {
$menu_items = $variables["content"]["#items"];
foreach ($menu_items as $name => $item) {
if (!$item['below']) {
unset($variables["content"]["#items"][$name]);
}
}
}
}