Verified Commit 1b3ec547 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3273317 by clayfreeman, larowlan, tim.plunkett, danflanagan8: Add...

Issue #3273317 by clayfreeman, larowlan, tim.plunkett, danflanagan8: Add 'in_preview' variable to block and layout templates

(cherry picked from commit 6483b299)
parent 69fa15a6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ public function build(array $regions) {
        $build[$region_name] = $regions[$region_name];
      }
    }
    $build['#in_preview'] = $this->inPreview;
    $build['#settings'] = $this->getConfiguration();
    $build['#layout'] = $this->pluginDefinition;
    $build['#theme'] = $this->pluginDefinition->getThemeHook();
+1 −0
Original line number Diff line number Diff line
@@ -246,6 +246,7 @@ function template_preprocess_block(&$variables) {
  $variables['plugin_id'] = $variables['elements']['#plugin_id'];
  $variables['base_plugin_id'] = $variables['elements']['#base_plugin_id'];
  $variables['derivative_plugin_id'] = $variables['elements']['#derivative_plugin_id'];
  $variables['in_preview'] = $variables['elements']['#in_preview'] ?? FALSE;
  $variables['label'] = !empty($variables['configuration']['label_display']) ? $variables['configuration']['label'] : '';
  $variables['content'] = $variables['elements']['content'];
  // A block's label is configuration: it is static. Allow dynamic labels to be
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
 *   - label_display: The display settings for the label.
 *   - provider: The module or other provider that provided this block plugin.
 *   - Block plugin specific settings will also be stored here.
 * - in_preview: Whether the plugin is being rendered in preview mode.
 * - content: The content of this block.
 * - attributes: array of HTML attributes populated by modules, intended to
 *   be added to the main container tag of this template.
+2 −0
Original line number Diff line number Diff line
@@ -143,6 +143,7 @@ public function testBuildView() {
            '#markup' => 'Test1',
          ],
        ],
        '#in_preview' => FALSE,
        '#settings' => [
          'label' => '',
        ],
@@ -243,6 +244,7 @@ public function testBuildForm() {
          '#process' => ['\Drupal\Core\Render\Element\RenderElement::processGroup'],
          '#pre_render' => ['\Drupal\Core\Render\Element\RenderElement::preRenderGroup'],
        ],
        '#in_preview' => FALSE,
        '#settings' => [
          'label' => '',
        ],
+1 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
 * Default theme implementation for a four-column 25%-25%-25%-25% layout.
 *
 * Available variables:
 * - in_preview: Whether the plugin is being rendered in preview mode.
 * - content: The content for this layout.
 * - attributes: HTML attributes for the layout <div>.
 *
Loading