daily pastebin goal
66%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top