Table of Contents |
---|
Table of Contents |
---|
maxLevel | 4 |
---|
minLevel | 2 |
---|
outline | true |
---|
class | toc |
---|
|
|
Summary
As of Blesta version 4.3.0, plugins may make tabs available when managing a service in the admin or client interface. In order to do so, plugins must be registered for the package by setting it under Plugin Integration when adding or updating a package. Once set on the package, the plugin's defined service management tabs will be visible when managing a service that uses that package.
...
Code Block |
---|
|
class MyPlugin extends Plugin
{
...
/**
* Returns all tabs to display to a client when managing a service
*
* @param stdClass $service A stdClass object representing the selected package
* @return array An array of tabs in the format of method => array where array contains:
* - name (required) The name of the link
* - icon (optional) use to display a custom icon
* - href (optional) use to link to a different URL
* Example: array('methodName' => "Title", 'methodName2' => "Title2")
* array('methodName' => array('name' => "Title", 'icon' => "icon"))
*/
public function getClientServiceTabs(stdClass $service)
{
return [
// Define a tab, 'tabTwo' that references a method on this class by the same name, MyPlugin::tabTwo
'tabTwo' => [
'name' => 'Tab Two'
],
// Define a tab, 'google' that links to another URL
'google' => [
'name' => 'Google',
'href' => 'https://google.com'
]
];
}
/**
* Displays the custom tab defined by ::getClientServiceTabs
*
* @param stdClass $service An stdClass object representing the service
* @param array $get The GET arguments
* @param array $post The POST fields
* @param array $files The FILES
* @return string The content of the tab
*/
public function tabTwo(stdClass $service, array $get = null, array $post = null, array $files = null)
{
$this->view = new View();
// Make the service available to the view
$this->view->set('service', $service);
// Load the view at /plugins/my_plugin/views/default/tab_twoone.pdt
$this->view->setView('tab_two', 'MyPlugin.default');
// Display a notice message on this tab page
$this->setMessage('notice', 'This is a test tab');
// Return the content of the view
return $this->view->fetch();
}
...
} |