function system_admin_compact_mode

Same name in other branches
  1. 7.x modules/system/system.module \system_admin_compact_mode()
  2. 9 core/modules/system/system.module \system_admin_compact_mode()
  3. 10 core/modules/system/system.module \system_admin_compact_mode()
  4. 11.x core/modules/system/system.module \system_admin_compact_mode()

Determines whether the current user is in compact mode.

Compact mode shows certain administration pages with less description text, such as the configuration page and the permissions page.

Whether the user is in compact mode is determined by a cookie, which is set for the user by \Drupal\system\Controller\SystemController::compactPage().

If the user does not have the cookie, the default value is given by the configuration variable 'system.site.admin_compact_mode', which itself defaults to FALSE. This does not have a user interface to set it: it is a hidden variable which can be set in the settings.php file.

Return value

bool TRUE when in compact mode, FALSE when in expanded mode.

3 calls to system_admin_compact_mode()
SystemCompactLink::preRenderCompactLink in core/lib/Drupal/Core/Render/Element/SystemCompactLink.php
Pre-render callback: Renders a link into #markup.
template_preprocess_admin_block_content in core/modules/system/system.admin.inc
Prepares variables for administrative content block templates.
UserPermissionsForm::buildForm in core/modules/user/src/Form/UserPermissionsForm.php
Form constructor.

File

core/modules/system/system.module, line 1124

Code

function system_admin_compact_mode() {
    // PHP converts dots into underscores in cookie names to avoid problems with
    // its parser, so we use a converted cookie name.
    return \Drupal::request()->cookies
        ->get('Drupal_visitor_admin_compact_mode', \Drupal::config('system.site')->get('admin_compact_mode'));
}

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