Embed Active List Components

Plesk SDK API allows you to embed information (currently only custom services) into certain items of existing Active List objects. To do that, implement the pm_Hook_ActiveList interface. It provides the following methods:

  • getItemServices($controller, $action, $itemId) returns the array of configuration parameters of the service that will be embedded in an item with id=$itemId list on /$contorller/$action page. Service configuration:
    • title - the title of the service.
    • icon - the icon of the service.
    • link - the link to the service (optional).
    • toolbar - an array of tools of service (optional).
    • messages - an array of service messages (optional).

To illustrate the approach, the following sample project is provided by Plesk: https://github.com/plesk/ext-active-list-hook

Example: Embedding custom services to Websites & Domains active list

src/plib/hooks/ActiveList.php

<?php
class Modules_<YourExtensionName>_ActiveList extends pm_Hook_ActiveList
{
    public function getItemServices($controller, $action, $itemId)
    {
        if ($controller !== 'web' || ($action !== 'view' && $action !== 'overview')) {
            return [];
        }
  
        return [
            [
                'icon' => pm_Context::getBaseUrl() . 'images/icon-service1.png',
                'title' => pm_Locale::lmsg('service1Title'),
                'link' => pm_Context::getActionUrl('service1', 'index') . '/id/' . $itemId,
                'toolbar' => [
                    [
                        'title' => pm_Locale::lmsg('action1Title'),
                        'link' => pm_Context::getActionUrl('service1', 'action1') . '/id/' . $itemId,
                    ],
                    [
                        'title' => pm_Locale::lmsg('action2Title'),
                        'link' => pm_Context::getActionUrl('service1', 'action2') . '/id/' . $itemId,
                    ],
                ],
            ],
            [
                'icon' => pm_Context::getBaseUrl() . 'images/icon-service2.png',
                'title' => pm_Locale::lmsg('service2Title'),
                'link' => pm_Context::getActionUrl('service2', 'index') . '/id/' . $itemId,
                'toolbar' => [
                    [
                        'title' => pm_Locale::lmsg('action3Title'),
                        'link' => pm_Context::getActionUrl('service2', 'action3') . '/id/' . $itemId,
                    ],
                ],
                'messages' => [
                    [
                        'icon' => pm_Context::getBaseUrl() . 'images/attention.png',
                        'info' => pm_Locale::lmsg('serviceMessage1'),
                        'noEscape' => true,
                    ],
                ],
            ],
        ];
    }
}
 

Leave your feedback on this topic here

If you have questions or need support, please visit the Plesk forum or contact your hosting provider.
The comments below are for feedback on the documentation only. No timely answers or help will be provided.