Add Buttons

Buttons are very similar to tabs, but there is one important difference from the user experience point of view: for tabs, there is a default page which is displayed, and, usually, not many tabs are used on a given page.

Big buttons are usually used to show all available operations, none of which are "default" or "most used". Good examples of big buttons from the Plesk UI are the buttons corresponding to domains on the Websites & Domains page, or the Tools & Utilities button in the reseller UI.

To add a button to a page you need to define them in the controller:

public function buttonsAction()
{
	$this->view->tools = [
		[
			'icon' => pm_Context::getBaseUrl() . "img/button1.png", 
			'title' => 'Button 1', 
			'description' => 'Example of link to controller and action', 
			'controller' => 'custom', 
			'action' => 'form', 
		], 
		[
			'icon' => pm_Context::getBaseUrl() . "img/button2.png", 
			'title' => 'Button 2', 
			'description' => 'Link to extension entry point', 
			'link' => pm_Context::getBaseUrl() , 
		], 
	];
}

Then render them in view (buttons.phtml) using the pm_View_Helper_RenderTools helper:

<?php echo $this->renderTools($this->tools); ?>

Now you can visit the buttons action of your extension and check the result. Moreover, you can see what the button would look like on a Plesk server using a different color scheme or branding (for example, when the Skins and Color Schemes extension is installed), or what the button would look like in adaptive design on a mobile device.

For more examples of how to use buttons, refer to the Amazon Route 53 extension found here (toolsAction of IndexController).

 

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.