1 layout_renderer_standard.inc LayoutRendererStandard::ensurePageContentBlock()

Ensure that the page content block is included in the default region.

This method is used specifically when the "default" layout is used, to make sure that the current page content is rendered in the default region of the fallback layout; thus ensuring the UI of the site remains usable.


core/modules/layout/plugins/renderers/layout_renderer_standard.inc, line 618


The standard render for a Layout display object.


function ensurePageContentBlock() {
  $page_content_uuid = NULL;
  $default_region = $this->layout_info['default region'];

  // Check that the page content block exists in the layout.
  foreach ($this->layout->content as $uuid => $block) {
    if ($block->module === 'system' && $block->delta === 'main') {
      $page_content_uuid = $uuid;

  // If no page content block found at all, create one on the fly.
  if (!$page_content_uuid) {
    $block = layout_create_handler('block', 'system:main');
    $block->uuid = 'default';
    $this->layout->content['default'] = $block;
    $page_content_uuid = $block->uuid;

  // Add the page content block to the default region in the first position.
  if (!isset($this->layout->positions[$default_region])) {
    $this->layout->positions[$default_region] = array();
  if (!in_array($page_content_uuid, $this->layout->positions[$default_region])) {
    array_unshift($this->layout->positions[$default_region], $page_content_uuid);