function template_preprocess_admin_block_content

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

Prepares variables for administrative content block templates.

Default template: admin-block-content.html.twig.

Parameters

$variables: An associative array containing:

  • content: List of administrative menu items. Each menu item contains:

    • url: Path to the admin section.
    • title: Short name of the section.
    • description: Description of the administrative menu item.
    • options: URL options. See \Drupal\Core\Url::fromUri() for details.

File

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

Code

function template_preprocess_admin_block_content(&$variables) {
    if (!empty($variables['content'])) {
        $variables['compact'] = system_admin_compact_mode();
        foreach ($variables['content'] as $key => $item) {
            $variables['content'][$key]['link'] = Link::fromTextAndUrl($item['title'], $item['url'])->toString();
            if (!$variables['compact'] && isset($item['description'])) {
                $variables['content'][$key]['description'] = [
                    '#markup' => $item['description'],
                ];
            }
            else {
                $variables['content'][$key]['description'] = FALSE;
            }
        }
    }
}

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