- πΊπΈUnited States tripodcreative
Here's an easier way to do this:
1). Copy admin-block.html.twig from core/modules/system/templates/admin-block.html.twig into your admin theme.
2). Add this twig:{% set class = block.title %} {% set class = class|replace({' ':''}) %} {% set class = class|lower %} {% set classes = [ 'panel', class, ] %} Then, the <code><div{{ attributes.addClass(classes) }}>
will include the class name of the region, in this case, admintoolbarsearch
Then, in your admin theme, just
div.admintoolbarsearch { display:none; }
- π©πͺGermany stefan.korn Jossgrund
The list that admin_toolbar_tools generate on admin/index is really cluttering the UI and the link titles are often confusing.
If you want to stop the output of admin_toolbar_tools before this actually is put on the site, you could use a Route Subscriber and override the core controller to exclude the links from admin_toolbar_tools.
Like so:
your_module.services.yml
services: your_module.route_subscriber: class: Drupal\your_module\Routing\RouteSubscriber tags: - { name: event_subscriber }
src/Routing/RouteSubscriber.php
<?php namespace Drupal\your_module\Routing; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\RouteCollection; class RouteSubscriber extends RouteSubscriberBase { protected function alterRoutes(RouteCollection $collection) { if ($route_index = $collection->get('system.admin_index')) { $route_index->setDefault('_controller', '\Drupal\your_module\Controller\AdminController::index'); } } }
src/Controller/AdminController
<?php namespace Drupal\your_module\Controller; /* * hide the admin toolbar extra tools entries on admin/index as it clutters the UI. */ class AdminController extends \Drupal\system\Controller\AdminController { public function index() { $output = parent::index(); if (isset($output['#menu_items']['Admin Toolbar Extra Tools'])) { unset($output['#menu_items']['Admin Toolbar Extra Tools']); } return $output; } }