On admin/content, I have created different views for articles and basic pages (the default content types created from Drupal). On admin/content, it shows Content | Article | Basic Page. When I already have Article and Basic page as separate.

On admin/content, I would like to show as Blank means no data instead of showing all data.

I tried the following code.


namespace Drupal\content\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

 * Listens to the dynamic route events.
class RouteSubscriber extends RouteSubscriberBase {

   * Used to alter routes.
  protected function alterRoutes(RouteCollection $collection) {
    if ($route = $collection->get('system.admin_content')) {
        '_controller' => '\Drupal\content\Controller\ContentOverviewController::overview',


I'm trying to override its default controller, so it show blank.

The code for the controller is the following one.

namespace Drupal\content\Controller;

use Drupal\system\Controller\SystemController;

 * Class ContentOverviewController.
class ContentOverviewController extends SystemController {

   * Content Overview.
  public function overview($link_id) {

    $build = [
      '#markup' => $this->t('Hello World!'),
    return $build;


The code doesn't seem to work.

I also tried to disable the content view, but that is not needed.

  • You can don't overwrite it
    – vinhdv
    Aug 21, 2018 at 12:16
  • 1
    That's not true. You can disable this view, and make a new view with the same URL.
    – Kevin
    Aug 21, 2018 at 19:43
  • Did you try add tag priority for your service? May be your service run before views.route_subscriber of view module.
    – MrD
    Aug 27, 2018 at 5:41

2 Answers 2


As per documentation:

The \Drupal\example\Routing\RouteSubscriber::alterRoutes method is an event subscriber because it extends RouteSubscriberBase. Therefore, the class must be registered as an event subscriber service.

In your example you also need a content.services.yml:

    class: Drupal\content\Routing\RouteSubscriber
      - { name: event_subscriber }
  • This worked for me. I had to extend a Controller and was missing the routing entry. Once I added it to *.routing.yml it worked. Thanks! Mar 9 at 15:37

Check a namespace in your RouteSubscriber.php

You have

namespace Drupal\content\Routing

Should be

namespace Drupal\mcontent\Routing

Because your custom module is mcontent (not content)

  • Fixed the things
    – Mighty
    Aug 21, 2018 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.