¡Hola, amigos! I’m Señor FAQ, the mustached maestro of questions and answers! With my trusty glasses and a book of endless wisdom, I turn dudas into solutions. Soy el héroe de los curiosos and the champion of clarity.
on_dashboard_top_boxes
The on_dashboard_top_boxes
hook allows plugins to add custom dashboard boxes dynamically in the admin panel's top section. Each box can display statistics, links, or any other relevant data for the user.
DynamicHooks::executeHook('on_dashboard_top_boxes', true);
true
, results from all hooks are flattened into a single array. Default is true
.(array) An array of dashboard box data, where each element represents a box with the following attributes:
id
: (string) A unique identifier for the box.icon
: (string) The icon class (e.g., fas fa-users
) for the box.icon_background
: (string) The background color class for the icon (e.g., bg-primary
).value
: (string) The main statistic or value to display in the box.subtitle
: (string) A brief description or subtitle for the box.link
: (string) A URL to redirect when the box is clicked.
DynamicHooks::addHook('on_dashboard_top_boxes', function () use ($jakdb, $lang) {
$totalUsers = $jakdb->count('users');
$totalOrders = $jakdb->count('orders');
return [
[
'id' => 'total_users_box',
'icon' => 'fas fa-users',
'icon_background' => 'bg-primary',
'value' => $totalUsers,
'subtitle' => $lang['total_users'],
'link' => DynamicRewrite::parseUrl('users'),
],
[
'id' => 'total_orders_box',
'icon' => 'fas fa-shopping-cart',
'icon_background' => 'bg-success',
'value' => $totalOrders,
'subtitle' => $lang['total_orders'],
'link' => DynamicRewrite::parseUrl('orders'),
]
];
}, 'my_plugin_namespace');
id
to avoid conflicts with other plugins.id
values for your boxes to avoid overwriting or breaking other plugin boxes.link
attribute points to a valid and accessible URL.