...
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 Any GET parameters * @param array $post Any POST parameters * @param array $files Any FILES parameters * @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_one.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(); } ... } |
Example
...
Plugin
Download the attached sample plugin that implements management tabs.
...