function template_preprocess_admin_block_content

Same name in other branches
  1. 9 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: An array containing information about the block. Each element of the array represents an administrative menu item, and must at least contain the keys 'title', 'link_path', and 'localized_options', which are passed to l(). A 'description' key may also be provided.

File

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

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.