function template_preprocess_system_admin_index

Same name in other branches
  1. 8.9.x core/modules/system/system.admin.inc \template_preprocess_system_admin_index()
  2. 10 core/modules/system/system.admin.inc \template_preprocess_system_admin_index()
  3. 11.x core/modules/system/system.admin.inc \template_preprocess_system_admin_index()

Prepares variables for admin index templates.

Default template: system-admin-index.html.twig.

Parameters

$variables: An associative array containing:

  • menu_items: An array of modules to be displayed.

File

core/modules/system/system.admin.inc, line 83

Code

function template_preprocess_system_admin_index(&$variables) {
    $variables['system_compact_link'] = [
        '#type' => 'system_compact_link',
    ];
    $variables['containers'] = [];
    $stripe = 0;
    // Iterate over all modules.
    foreach ($variables['menu_items'] as $module => $block) {
        [
            $description,
            $items,
        ] = $block;
        $position = ++$stripe % 2 ? 'left' : 'right';
        // Output links.
        if (count($items)) {
            $variables['containers'][$position][] = [
                '#theme' => 'admin_block',
                '#block' => [
                    'position' => $position,
                    'title' => $module,
                    'content' => [
                        '#theme' => 'admin_block_content',
                        '#content' => $items,
                    ],
                    'description' => t($description),
                ],
            ];
        }
    }
}

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