Hooks in the Management Panel
The 87 points that add to a screen in the management panel. Plus the 7 hooks making a new capability known to it.
Overview
The panel takes two kinds of widening. Screen points add HTML to a page that already exists. Registration hooks make something new known to the panel: a menu entry, a dashboard box, a permission, a report.
The two serve different jobs. Putting information in a corner of a screen is a screen point. Opening a page and a permission of your own is a registration hook.
Structure
Panel templates are plain PHP and a hook point is called inside the template itself. The naming follows the same pattern as the customer site: family, screen, spot.
<?php foreach (Hook::run('ui:admin.client_detail.bottom', $user, $user_id) as $html)
echo $html;
Reference
Screen points
How the eighty-seven points spread across the screens. List and edit screens follow a shared pattern, so a point you find on one usually exists on its siblings too.
Registration hooks
Seven registration hooks. Their contracts differ from one another. Some want a registration array returned. Some want you to add to a structure handed to you, and ignore your return. Read the entry before writing.
Two contracts
// A BOX: the definition array is RETURNED
Hook::add('register:admin.dashboard_widgets', 10, function () {
return ['name' => 'Acme', 'status' => 'open', 'size' => 6];
});
// THE MENU: the return is ignored and the change goes through the global menu structure
Hook::add('register:admin.menu', 10, function () {
$GLOBALS['menus']['acme'] = ['name' => 'Acme', 'link' => 'acme/report'];
});
Pitfalls
The menu hook puts the link there and nothing else. The page itself still wants a permission, and a separate registration hook makes that permission known. Without both, an operator sees the entry and gets a refused answer on clicking it.
On the customer site a hook is called with a template tag. In the panel it is a direct PHP call and the returns are echoed by hand. So how many values a point passes changes from screen to screen. Check the parameters against the hook's entry.
Some of the seven want you to return an array and some want you to add to a structure handed to you. Getting it the wrong way round is silent: you return your array, nothing appears, and no error is raised.
These points run on signed-in staff pages alone, so a customer never sees them. Even so, filter what you show by the staff member's permissions: not every operator should see everything.
Related Articles
- Management Panel Data and Gates
- Hooks on the Customer Site
- Module Lifecycle Hooks
Thanks for your feedback!
Our support team is here around the clock for anything you can't find above.