Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagephp
class MyPlugin extends Plugin 
{
...
	/**
     * Returns all tabs to display to an admin when managing a service
     *
     * @param stdClass $service An stdClass object representing the selected service
     * @return array An array of tabs in the format of method => array where array contains:
     *  - name (required) The name of the link
     *  - href (optional) use to link to a different URL
     *      Example: array('methodName' => "Title", 'methodName2' => "Title2")
     *      array('methodName' => array('name' => "Title", 'href' => "https://blesta.com"))
     */
    public function getAdminServiceTabs(stdClass $service)
    {
		return [
			// Define a tab, 'tabOne' that references a method on this class by the same name, MyPlugin::tabOne
            'tabOne' => [
                'name' => 'Tab One'
            ],
			// Define a tab, 'google' that links to another URL
            'google' => [
                'name' => 'Google',
                'href' => 'https://google.com'
            ]
        ];
    }

    /**
     * Displays the custom tab defined by ::getAdminServiceTabs
     * 
     * @param stdClass $service An stdClass object representing the service
     * @param array $get TheAny GET argumentsparameters
     * @param array $post TheAny POST fieldsparameters
     * @param array $files TheAny FILES parameters
     * @return string The content of the tab
     */
    public function tabOne(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_one', 'MyPlugin.default');

		// Return the content of the view
        return $this->view->fetch();
	}
...
}

...

Code Block
languagephp
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 TheAny GET argumentsparameters
     * @param array $post TheAny POST fieldsparameters
     * @param array $files TheAny 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();
	}
...
}

...