
How We Build Fully Custom Dashboards

Want a smarter admin experience in Drupal 10? At Arudhra IT Techs, we build dashboards that are fully role-based, powered by custom code, AJAX, and dynamic data — not generic blocks. This guide shows how we build these dashboards with real examples and deep integration into the Drupal ecosystem.
How We Build Fully Custom Dashboards in Drupal 10: Role-Based UI, Reports & Admin UX
At Arudhra IT Techs, we specialize in building custom dashboards in Drupal 10 that are more than just a bunch of blocks. Our dashboards are role-based, permission-controlled, report-driven, and optimized for productivity — built using custom modules, Views, AJAX, and secure layouts.
🔐 Step 1: Role-Based Routing for Your Dashboard
We always start by registering a route that only a specific role can access:
# my_module.routing.yml
my_module.admin_dashboard:
path: '/admin/dashboard'
defaults:
_controller: '\Drupal\my_module\Controller\AdminDashboardController::dashboard'
_title: 'Admin Dashboard'
requirements:
_permission: 'access admin dashboard'
options:
_admin_route: TRUE
🔑 Keyword: Drupal 10 route access is permission-controlled. You can also use _role
if needed for role-specific dashboards.
🧠 Step 2: Create the Controller and Layout
In the controller, we load dynamic content blocks, charts, or View render arrays based on user role.
// src/Controller/AdminDashboardController.php
namespace Drupal\my_module\Controller;
use Drupal\Core\Controller\ControllerBase;
class AdminDashboardController extends ControllerBase {
public function dashboard() {
return [
'#theme' => 'admin_dashboard',
'#data' => [
'user_count' => $this->getUserCount(),
'latest_orders' => $this->getLatestOrders(),
],
];
}
private function getUserCount() {
$query = \Drupal::entityQuery('user')->count()->execute();
return $query;
}
private function getLatestOrders() {
// Load data from a custom entity, orders, or commerce.
$storage = \Drupal::entityTypeManager()->getStorage('commerce_order');
return $storage->loadMultiple(5);
}
}
🔑 Keyword: This is a basic custom Drupal 10 dashboard controller — you can output render arrays, render Views, or theme custom templates.
🧩 Step 3: Custom Twig Template for Dashboard
Your template file (e.g., admin-dashboard.html.twig
) can contain cards, charts, or table components:
Total Users
{{ data.user_count }}
Recent Orders
{% for order in data.latest_orders %}
{{ order.label }}
{% endfor %}
📊 Step 4: Inject Drupal Views into Your Dashboard
You can render Views directly into your controller using the following method:
$view = \Drupal\views\Views::getView('user_report');
$view->setDisplay('block_1');
$view->preExecute();
$view->execute();
$build = $view->render();
🔑 Keyword: Injecting Views into Drupal 10 dashboard is a powerful way to build visual reports and filters.
📋 Step 5: Secure Admin UX with Permissions
In your my_module.permissions.yml
file, define permissions like:
access admin dashboard:
title: 'Access custom admin dashboard'
description: 'Allows access to the Drupal 10 dashboard.'
Assign it per role, and create unique dashboards for:
- 🧑💼 Admin
- 📦 Vendor
- 💬 Manager
⚡ Step 6: Add AJAX and Dynamic Filters
Want live stats, toggle widgets, or filters? Use AJAX in your form:
$form['filter'] = [
'#type' => 'select',
'#options' => [1 => 'Today', 7 => 'This Week', 30 => 'This Month'],
'#ajax' => [
'callback' => '::updateDashboardContent',
'wrapper' => 'dashboard-content',
],
];
$form['dashboard_content'] = [
'#type' => 'container',
'#attributes' => ['id' => 'dashboard-content'],
];
🔑 Keyword: AJAX-based Drupal dashboard keeps things reactive and smooth.
📂 Step 7: Custom Block Plugins for Dashboard Widgets
For reusable widgets across admin pages, create a custom block:
// src/Plugin/Block/UserStatsBlock.php
namespace Drupal\my_module\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* @Block(
* id = "user_stats_block",
* admin_label = @Translation("User Stats Block")
* )
*/
class UserStatsBlock extends BlockBase {
public function build() {
$count = \Drupal::entityQuery('user')->count()->execute();
return [
'#markup' => "$count users",
];
}
}
🔑 Keyword: Drupal 10 dashboard widgets should be built as custom block plugins for reusability and performance.
🧪 Bonus: Export Reports as PDF or CSV
Use dompdf or Mpdf libraries to generate reports from Views or tables:
$html = 'User Report...';
$dompdf = new \Dompdf\Dompdf();
$dompdf->loadHtml($html);
$dompdf->render();
$dompdf->stream("user-report.pdf");
🔑 Keyword: Add PDF export to Drupal dashboard for admin report generation.
Final Word: Dashboards That Run the Show
Drupal 10 is not just for content — with custom routes, Views, blocks, and AJAX, you can build fully dynamic, role-specific dashboards that admins love. We build dashboards that support operations, vendors, product data, sales reports, user insights, and more — all secured and scalable.
Need a smart admin dashboard in Drupal 10? Let’s build it the right way 👇