$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);
$block_manager = \Drupal::service('plugin.manager.block');
| <!DOCTYPE html> | |
| <html<?php print $html_attributes; ?>> | |
| <head> | |
| <?php print $head; ?> | |
| <title><?php print $head_title; ?></title> | |
| <?php print $styles; ?> | |
| <?php print $head_scripts; ?> | |
| </head> | |
| <body<?php print $body_attributes;?>> |
| <?php | |
| // Load the currently logged in user. | |
| global $user; | |
| // Check if the user has the 'editor' role. | |
| if (in_array('editor', $user->roles)) { | |
| // do fancy stuff | |
| } | |
| ?> |
| <?php | |
| \Drupal::theme()->getActiveTheme()->getPath(); | |
| ?> |
| <?php | |
| /** | |
| * Implements hook_theme_suggestions_HOOK_alter(). | |
| */ | |
| function MYTHEME_theme_suggestions_block_alter(array &$suggestions, array $variables) | |
| { | |
| $block = $variables['elements']; | |
| $blockType = $block['#configuration']['provider']; | |
| if ($blockType == "block_content") { |
| /** | |
| * Implements hook_theme_suggestions_HOOK_alter(). | |
| */ | |
| function MYTHEME_theme_suggestions_image_formatter_alter(array &$suggestions, array $variables) { | |
| $entity = $variables['item']->getEntity(); | |
| $field_name = $variables['item']->getParent()->getName(); | |
| $suggestions[] = 'image_formatter__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name; | |
| } |
| {# | |
| /** | |
| * @file | |
| * Default theme implementation of an image. | |
| * | |
| * Available variables: | |
| * - attributes: HTML attributes for the img tag. | |
| * - style_name: (optional) The name of the image style applied. | |
| * | |
| * @see template_preprocess_image() |
| {{ dump(_context|keys) }} |
| {# isAdmin? #} | |
| {% if UserID == '1' %} | |
| {{ kint() }} | |
| {% endif %} |