I'm trying to add a Moderation Dashboard tab to the user page like the Moderation Dashboard module, but I can't use Panels. Is it possible to create a layout on a route using layout builder?
I've created the route in msk_module/my_module.routing.yml
with
my_module.moderation_dashboard:
path: '/user/{user}/dashboard'
defaults:
_title: 'Moderation Dashboard'
_controller: '\Drupal\my_module\Controller\MyModuleDashboardController::index'
requirements:
_user_is_logged_in: 'TRUE'
And the links task in msk_module/my_module.links.task.yml
with
my_module.moderation_dashboard:
route_name: my_module.moderation_dashboard
base_route: entity.user.canonical
title: 'Moderation Dashboard'
weight: 30
And started the controller in msk_module/src/Controller/MyModuleDashboardController.php
with
<?php
namespace Drupal\my_module\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Controller for moderation dashboard.
*/
class MyModuleDashboardController extends ControllerBase {
/**
* Display the markup.
*
* @return array
* Return markup array.
*/
public function index() {
return [
'#type' => 'markup',
'#markup' => $this->t('Hello, World!'),
];
}
}
So the tab is where I want it. The contents for the tab are the block views displays from the views from Moderation Dashboard. I suppose I can use hook_theme() and a template and some small amount of CSS. Just wondering if layout builder can do the same thing as the panel in page manager can do?