- 🇬🇷Greece dspachos
Hi, you need to implement a custom hook, something like that:
/** * Implements hook_menu_local_tasks_alter() */ function MYMODULE_menu_local_tasks_alter(&$data, $route_name, RefinableCacheableDependencyInterface &$cacheability) { if ($route_name == 'system.admin_content') { unset($data['tabs'][1]['content_moderation.content']); } }
- 🇨🇦Canada fengtan Montreal, Canada
I ran into this as well.
This is because the path
/admin/content/moderated
is served by both:- A view (
content_moderated
) https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/conte... - And a controller (
content_moderation.admin_moderated_content
) https://git.drupalcode.org/project/drupal/-/blob/11.x/core/modules/conte...
So, if you disable the view, then
/admin/content/moderated
will not go away and will be served by the controller instead. It looks like there is no way to remove/admin/content/moderated
unless you disable the route altogether (as shown by #5 above). - A view (
- 🇨🇦Canada fengtan Montreal, Canada
Here is how I removed the "Moderated content" tab. This will always deny access to
/admin/content/moderated
(assuming the viewcontent_moderated
has also been disabled).// web/modules/custom/mymodule/src/Routing/MyModuleRouteSubscriber.php namespace Drupal\mymodule\Routing; use Drupal\Core\Routing\RouteSubscriberBase; use Symfony\Component\Routing\RouteCollection; class MyModuleRouteSubscriber extends RouteSubscriberBase { /** * {@inheritdoc} */ protected function alterRoutes(RouteCollection $collection) { // Always deny access to /admin/content/moderated (assuming view 'content_moderated' has been disabled). if ($route = $collection->get('content_moderation.admin_moderated_content')) { // Second parameter must be a string, see https://www.drupal.org/docs/drupal-apis/routing-system/altering-existing-routes-and-adding-new-routes-based-on-dynamic-ones#s-altering-existing-routes $route->setRequirement('_access', 'FALSE'); } } }