Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 4 characters in body
Source Link
Mighty
  • 221
  • 2
  • 13

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.

modules/custom/mcontent/src/Routing/RouteSubscriber.php

modules/custom/content/src/Routing/RouteSubscriber.php

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')) {
      $route->setDefaults(array(
        '_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\mcontent\Controller;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.

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.

modules/custom/mcontent/src/Routing/RouteSubscriber.php

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')) {
      $route->setDefaults(array(
        '_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\mcontent\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.

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.

modules/custom/content/src/Routing/RouteSubscriber.php

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')) {
      $route->setDefaults(array(
        '_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.

improved grammar
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

How to Overwrite Admin Contentdo I overwrite the controller for admin/content?

On admin/contentadmin/content, I have created different views for Article & Basic page

So once you are onarticles and basic pages (the default content types created from Drupal). On admin/content, it shows

Content | Article | Basic Page

Now when Content | Article | Basic Page. When I already have Article & Basic pageArticle and Basic page as separate.

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

What I have tried the following code.

modules/custom/mcontent/src/Routing/RouteSubscriber.php

modules/custom/mcontent/src/Routing/RouteSubscriber.php

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')) {
      $route->setDefaults(array(
        '_controller' => '\Drupal\content\Controller\ContentOverviewController::overview',
      ));
    }
  }

}

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

& InThe code for the controller is the following one.

namespace Drupal\mcontent\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;
  }

}

But above seems not workingThe code doesn't seem to work.

I also tried to Disable Content Viewdisable the content view, but that is not needed.

How to Overwrite Admin Content controller?

On admin/content I have created different views for Article & Basic page

So once you are on admin/content it shows

Content | Article | Basic Page

Now when I already have Article & Basic page as separate.

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

What I have tried

modules/custom/mcontent/src/Routing/RouteSubscriber.php

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')) {
      $route->setDefaults(array(
        '_controller' => '\Drupal\content\Controller\ContentOverviewController::overview',
      ));
    }
  }

}

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

& In controller

namespace Drupal\mcontent\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;
  }

}

But above seems not working.

I also tried to Disable Content View, but that is not needed.

How do I overwrite the controller for admin/content?

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.

modules/custom/mcontent/src/Routing/RouteSubscriber.php

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')) {
      $route->setDefaults(array(
        '_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\mcontent\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.

Source Link
Mighty
  • 221
  • 2
  • 13

How to Overwrite Admin Content controller?

On admin/content I have created different views for Article & Basic page

So once you are on admin/content it shows

Content | Article | Basic Page

Now when I already have Article & Basic page as separate.

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

What I have tried

modules/custom/mcontent/src/Routing/RouteSubscriber.php

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')) {
      $route->setDefaults(array(
        '_controller' => '\Drupal\content\Controller\ContentOverviewController::overview',
      ));
    }
  }

}

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

& In controller

namespace Drupal\mcontent\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;
  }

}

But above seems not working.

I also tried to Disable Content View, but that is not needed.