SHARE
TWEET

Untitled

a guest Jul 6th, 2017 246 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Files
  2. /modules/ts_events/
  3. /modules/ts_events/templates/block--ts-events.html.twig
  4. /modules/ts_events/ts_events.info.yml
  5. /modules/ts_events/ts_events.module //<-- code.
  6. /modules/ts_events/config //<-- files to create custom block
  7.  
  8. //Code
  9.  
  10. <?php
  11. function ts_events_theme() {
  12.   $theme['block__ts_events'] = [
  13.     'template' => 'block--ts-events',
  14.   ];
  15.  
  16.     return $theme;
  17. }
  18.  
  19. function ts_events_theme_suggestions_block_alter(array &$suggestions, array $variables) {
  20.   $content = $variables['elements']['content'];
  21.   if (isset($content['#block_content']) && $content['#block_content'] instanceof \Drupal\block_content\BlockContentInterface) {
  22.     $suggestion = 'block__' . $content['#block_content']->bundle();
  23.     array_splice( $suggestions, 1, 0, $suggestion );
  24.   }
  25. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top