Skip to main content

How to remove a primary tab from the admin menu in drupal 10

/**
 *  Implements hook_menu_local_tasks_alter().
 */
function pixelthis_menu_local_tasks_alter(&$data, $route_name, RefinableCacheableDependencyInterface &$cacheability) {

  if ($route_name !== 'system.admin_content' || empty($data['tabs'])) {
    return;
  }

  // Remove old paragraphs library item.
  foreach ($data['tabs'] as $key => $tab) {
    foreach ($tab as $tab_link_key => $tab_link_value) {
      if ($tab_link_key === 'entity.something.something_else') {
        unset($data['tabs'][$key][$tab_link_key]);
        break;
      }
    }
  }
}

 

hook

Latest Articles

Using drupal/core-composer-scaffold to prevent rewriting .htaccess or robots.txt file admin_pixelthi… Sun, 12/01/2024 - 16:49 Using drupal/core-composer-scaffold to prevent rewriting .htaccess or robots.txt file

Using drupal/core-composer-scaffold to prevent rewriting .htaccess or robots.txt file

composer
Controlling ckeditor styling options with hook_editor_js_settings_alter admin_pixelthi… Thu, 05/16/2024 - 10:49 Controlling ckeditor styling options with hook_editor_js_settings_alter

Controlling ckeditor styling options with hook_editor_js_settings_alter

php hook hook_editor_js_settings_alter hook_field_widget_single_[WIDGET_TYPE]_form_alter
Upgrading Drupal 9 Modules for Drupal 10: A Simple Guide admin_pixelthi… Tue, 09/05/2023 - 14:18 Upgrading Drupal 9 Modules for Drupal 10: A Simple Guide

Upgrading Drupal 9 Modules for Drupal 10: A Simple Guide

composer drupal9 drupal10