function SystemAdminThemePreprocess::preprocessAdminPage

Prepares variables for administrative index page templates.

Default template: admin-page.html.twig.

Parameters

array $variables: An associative array containing:

  • blocks: An array of blocks to display. Each array should include a 'title', a 'description', a formatted 'content' and a 'position' which will control which container it will be in. This is usually 'left' or 'right'.

File

core/modules/system/src/Theme/SystemAdminThemePreprocess.php, line 75

Class

SystemAdminThemePreprocess
Hook implementations for system.

Namespace

Drupal\system\Theme

Code

public function preprocessAdminPage(array &$variables) : void {
  $variables['system_compact_link'] = [
    '#type' => 'system_compact_link',
  ];
  $variables['containers'] = [];
  $stripe = 0;
  foreach ($variables['blocks'] as $block) {
    if (!empty($block['content']['#content'])) {
      if (empty($block['position'])) {
        // Perform automatic striping.
        $block['position'] = ++$stripe % 2 ? 'left' : 'right';
      }
      $variables['containers'][$block['position']]['blocks'][] = [
        '#theme' => 'admin_block',
        '#block' => $block,
      ];
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.