Guest User

Untitled

a guest
Aug 10th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. function THEME_NAME_theme_suggestions_block_alter(array &$suggestions, array $variables) {
  2. $current_path = Drupal::service('path.current')->getPath();
  3. $result = Drupal::service('path.alias_manager')->getAliasByPath($current_path);
  4.  
  5. $path_alias = trim($result, '/');
  6. $path_alias = str_replace('/', '-', $path_alias);
  7. $path_alias = str_replace('-', '_', $path_alias);
  8. $id = $variables['id'];
  9.  
  10. $suggestions[] = 'block__path_alias__'.$path_alias;
  11. $suggestions[] = 'block__' . $id . '__path_alias__'.$path_alias;
  12. }
Add Comment
Please, Sign In to add comment